#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n'
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll N, M;
cin >> N >> M;
vector<ll> arr;
for (int i = 1; i <= N; ++i) {
ll a;
cin >> a;
ll val = a - i * M;
if (val <= 0) {
arr.push_back(val);
}
}
if (arr.empty()) {
cout << N << endl;
return 0;
}
vector<ll> tails;
for (ll x : arr) {
ll target = -x;
auto it = upper_bound(tails.begin(), tails.end(), target);
if (it == tails.end()) {
tails.push_back(target);
}
else {
*it = target;
}
}
ll ans = N - tails.size();
cout << ans << endl;
}