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