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