#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) - '0' + ch;
    ch = getchar();
  }
  return x * f;
}
int main() {
  priority_queue<int> q;
  int n = read(), T = read();
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int x = read();
    x = max(x, i);
    while (!q.empty() && q.top() >= T - i) {
      q.pop();
    }
    if (x < T) q.push(x - i);
    ans = max(ans, (int)q.size());
  }
  printf("%d\n", ans);
}
