#include <bits/stdc++.h>
using namespace std;
const int MXN = 2e5 + 1;
long long N, T, A[MXN];
bool cnt[MXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> T;
  priority_queue<pair<long long, long long> > pq;
  for (int x = 0, ThxDem = N; x < ThxDem; ++x) {
    cin >> A[x];
    A[x] = max(0LL, A[x] - (x + 1LL));
    pq.push({-A[x], x});
  }
  int ans = 0, tmp = 0, i = N - 1;
  while (!pq.empty()) {
    pair<long long, long long> tmpP = pq.top();
    pq.pop();
    while (i >= 0 && i + 1 - tmpP.first >= T) tmp -= cnt[i], i--;
    if (tmpP.second <= i) cnt[tmpP.second] = 1, tmp++;
    ans = max(ans, tmp);
  }
  cout << ans << "\n";
  return 0;
}
