#include <bits/stdc++.h>
using namespace std;
int input() {
  int res = 0;
  char c = ' ';
  while (c < '0' && c != '-') c = getchar();
  while (c >= '0') res = res * 10 + (c - '0'), c = getchar();
  return res;
}
const int N = 2e5 + 1;
pair<int, int> sl[N << 1];
int main() {
  int n = input(), T = input(), cur = 0, ans = 0, sz = 0;
  for (int i = 1; i <= n; ++i) {
    int t = input(), l = max(0, t - i), r = T - i - 1;
    if (l > r) continue;
    sl[sz++] = {l, -1}, sl[sz++] = {r, 1};
  }
  sort(sl, sl + sz);
  for (int i = 0; i < sz; ++i) {
    cur -= sl[i].second;
    ans = max(ans, cur);
  }
  cout << ans;
}
