#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class T, class T1>
inline bool chkmax(T &x, const T1 &y) {
  return x < y ? x = y, true : false;
}
template <class T, class T1>
inline bool chkmin(T &x, const T1 &y) {
  return x > y ? x = y, true : false;
}
const int MAXN = 200001;
int n, t;
int a[MAXN];
map<int, int> f;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n >> t;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    int s = max(0, a[i] - i);
    int T = t - i;
    if (T < s) {
      continue;
    }
    f[s]++;
    f[T]--;
  }
  int ans = 0, help = 0;
  for (auto it : f) {
    help += it.second;
    chkmax(ans, help);
  }
  cout << ans << '\n';
  return EXIT_SUCCESS;
}
