#include <bits/stdc++.h>
using namespace std;
long long n, T, m, p, q, r;
long long ara[300000];
long long fnc(long long tm) {
  long long re = 0;
  for (long long i = 1; i <= n; i++) {
    if (tm + i >= T) break;
    if (tm + i >= ara[i]) re++;
  }
  return re;
}
int main() {
  cin >> n >> T;
  for (long long i = 1; i <= n; i++) cin >> ara[i];
  long long low = 0, high = T - 1;
  long long ans = 0;
  while (low < high) {
    if (high - low <= 1000) {
      for (long long i = low; i <= high; i++) {
        ans = max(ans, fnc(i));
      }
      break;
    }
    long long mid1 = (2 * low + high) / 3;
    long long mid2 = (low + 2 * high) / 3;
    long long tmp1 = fnc(mid1);
    long long tmp2 = fnc(mid2);
    if (tmp1 > tmp2) {
      high = mid2;
    } else {
      low = mid1;
    }
  }
  cout << min(ans, n) << endl;
  return 0;
}
