#include <bits/stdc++.h>
using namespace std;
int a[200010];
int main() {
  int n, T;
  scanf("%d%d", &n, &T);
  int ans = 0, cnt = 0;
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (i + 1 >= T || a[i] >= T) continue;
    a[i] -= i + 1;
    if (a[i] < 0) a[i] = 0;
    while (m.size() && -m.begin()->first + i + 1 >= T) {
      if (ans < cnt) ans = cnt;
      cnt -= m.begin()->second;
      m.erase(m.begin());
    }
    cnt++;
    m[-a[i]]++;
  }
  if (ans < cnt) ans = cnt;
  printf("%d\n", ans);
  return 0;
}
