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