#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:36777216")
using namespace std;
const int MAX_N = 1234567;
int by[MAX_N];
int main() {
  long long T, n;
  cin >> n >> T;
  vector<int> t(n);
  for (auto& x : t) cin >> x;
  long long ans = 0, cur = 0;
  for (int i = 0; i < min(n, T - 1); i++) {
    if (t[i] <= T - 1) {
      cur++;
      int by_pos = (T - 1 - t[i]) + i + 1;
      if (by_pos < n) by[by_pos]++;
    }
    cur -= by[i];
    ans = max(ans, cur);
  }
  cout << ans;
  return 0;
}
