#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios::sync_with_stdio(false);
  register int i;
  register priority_queue<int> Queue;
  register int N, T;
  cin >> N >> T;
  register int Ans;
  Ans = 0;
  for (i = 1; i <= N; i += 1) {
    while (!Queue.empty() && Queue.top() >= T - i) {
      Queue.pop();
    }
    register int X;
    cin >> X;
    if (max(X, i) < T) {
      Queue.push(X - i);
    }
    Ans = max(Ans, (int)Queue.size());
  }
  cout << Ans << endl;
  return 0;
}
