#include <bits/stdc++.h>
using namespace std;
long long n, m, a[200005], ans;
priority_queue<long long> pq;
signed main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; cin >> a[i++])
    ;
  for (long long i = 1; i <= n; i++) {
    while (!pq.empty() && pq.top() >= m - i) pq.pop();
    if (a[i] < m && i < m) pq.push(a[i] - i);
    ans = max(ans, (long long)pq.size());
  }
  cout << ans << endl;
  return 0;
}
