#include <bits/stdc++.h>
using namespace std;
priority_queue<int> pq;
int main() {
  int n, T, t, ans = 0;
  scanf("%d%d", &n, &T);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &t);
    t = max(t, i);
    if (i == 1) {
      if (t < T) ans = 1;
    } else {
      while (!pq.empty() && pq.top() + i >= T) pq.pop();
      ans = max(ans, (int)pq.size());
    }
    pq.push(t - i);
    if (pq.top() + i < T) ans = max(ans, (int)pq.size());
  }
  printf("%d\n", ans);
  return 0;
}
