#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e16 + 9;
const int inf = 1e9 + 9;
const int mod = 1e9 + 7;
const int N = 3e6 + 9;
const int kokn = 350;
const int logN = 18;
long long n, T, t[N], dp[N], ans;
map<long long, long long> MP;
int main() {
  scanf("%lld %lld", &n, &T);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &t[i]);
    long long lf = max(0LL, t[i] - i);
    long long rg = T - i - 1;
    if (lf <= rg) {
      MP[lf]++;
      MP[rg + 1]--;
    }
  }
  ans = 0;
  long long cur = 0;
  map<long long, long long>::iterator it;
  for (it = MP.begin(); it != MP.end(); it++) {
    cur += it->second;
    ans = max(ans, cur);
  }
  printf("%lld\n", ans);
  return 0;
}
