#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, t;
int TM[maxn], wait, ans;
priority_queue<int> in;
int main() {
  scanf("%d%d", &n, &t);
  for (int i = 1; i <= n; ++i) scanf("%d", &TM[i]);
  for (int i = 1; i <= n + 1; ++i) {
    wait = t - i;
    if (wait < 0) break;
    while (!in.empty() && in.top() > wait) in.pop();
    ans = max(ans, (int)in.size());
    in.push(TM[i] - i);
  }
  printf("%d\n", ans);
  return 0;
}
