// author: khba
#include "bits/stdc++.h"
using namespace std;
#define int long long
const int inf = (int)1e18;
#ifdef khba
#include "C:\Users\Asus\Desktop\khba\debug.h"
#else
#define print(...) 42
#endif
int32_t main() {
#ifdef khba
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, M, add = 0;
cin >> n >> M;
vector<int> a(n);
for (int& i : a) cin >> i;
vector <int> b;
for (int i = 0; i < a.size(); ++i) {
a[i] -= (i + 1) * M, a[i] = -a[i];
if (a[i] < 0) add += 1;
else b.push_back(a[i]);
}
a.swap(b);
vector<int> dp{-inf};
for (int i = 0; i < a.size(); ++i) {
auto it = lower_bound(begin(dp), end(dp), a[i]);
if (it == dp.end())
dp.push_back(a[i]);
else if (*it > a[i])
*it = a[i];
}
print(add, a.size(), dp.size());
cout << a.size() - (a.empty() ? 0 : dp.size()) + add;
return 0;
}
/*
j < i
h[i] - 0 <= i * M
h[i] <= M * i
h[i] - h[j] <= (i - j) * M
h[i] - h[j] <= i * M - j * M
h[i] - i * M <= h[j] - j * M
*/