#include <bits/stdc++.h>
using namespace std;
int n, t, a[200005];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> t;
  int tt = t - 1;
  for (int i = 1; i <= n; i++) cin >> a[i];
  priority_queue<int> q;
  int ans = 0;
  t--;
  for (int i = 1; i <= min(n, tt); i++) {
    t--;
    q.push(a[i] - i);
    while (!q.empty() && q.top() > t) q.pop();
    ans = max(ans, (int)q.size());
  }
  cout << ans << endl;
  return 0;
}
