#include <bits/stdc++.h>
using namespace std;
int a[200200];
int h[200200], hn, ans;
bool cmp(int p1, int p2) { return p1 > p2; }
int main() {
  ios_base::sync_with_stdio(false);
  int n, T, cnt = 0;
  cin >> n >> T;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    int temp = T - max(a[i], i + 1) + i;
    cnt++;
    if (temp <= i)
      cnt--;
    else {
      h[hn++] = temp;
      push_heap(h, h + hn, cmp);
    }
    while (hn > 0 && h[0] <= i) {
      pop_heap(h, h + hn, cmp);
      hn--;
      cnt--;
    }
    if (cnt > ans) ans = cnt;
  }
  cout << ans << "\n";
  return 0;
}
