#include <bits/stdc++.h>
// meeeooowwwww mrrowwww :3
// go play vivid/stasis!! now!!!! https://vividstasis.gay
#define fo(i, a, b) for (auto i = (a); i < (b); i++)
#define of(i, a, b) for (auto i = (b); i-- > (a);)
#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define be(a) a.begin(), a.end()
using namespace std;
int ____init = []{
ios::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
return 0;
}();
int l;
vector<int> elephants;
multiset<int> positions;
void init(int n, int _l, int x[]) {
l = _l;
fo(i, 0, n) elephants.pb(x[i]), positions.insert(x[i]);
}
int update(int i, int v) {
positions.erase(positions.lb(elephants[i]));
positions.insert(elephants[i] = v);
int res = 0;
for (auto it = positions.begin(); it != positions.end(); it = positions.ub(*it + l)) res++;
return res;
}