#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
// Fast I/O
ios::sync_with_stdio(false);
cin.tie(NULL);
int N;
long long M;
if (!(cin >> N >> M)) return 0;
vector<long long> y;
for (int i = 1; i <= N; ++i) {
long long h;
cin >> h;
// Only consider poles that could potentially be reached from height 0
if (h <= (long long)i * M) {
y.push_back((long long)i * M - h);
}
}
// Find the Longest Non-Decreasing Subsequence (LNDS) of y
// We use the standard O(N log N) tails approach
vector<long long> tails;
for (long long val : y) {
// upper_bound finds the first element > val
// This allows us to maintain a non-decreasing sequence
auto it = upper_bound(tails.begin(), tails.end(), val);
if (it == tails.end()) {
tails.push_back(val);
} else {
*it = val;
}
}
// Smallest modifications = Total poles - Max poles kept
cout << N - (int)tails.size() << endl;
return 0;
}