#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int,int>> vv;
vector<int> v;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
int a; cin >> a;
vv.emplace_back(m * i - a, i);
}
vv.emplace_back(0, 0);
sort(vv.begin(),vv.end());
bool pass = 0;
for (auto [val, x] : vv) {
//cout << val << " " << x << endl;
if (x == 0) {
pass = 1;
continue;
}
if (!pass) continue;
auto it = upper_bound(v.begin(), v.end(), x);
if (it == v.end()) v.push_back(x);
else *it = x;
}
cout << n - v.size();
}