#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const long long INFL = 1e18 + 123;
const double PI = atan2(0, -1);
mt19937 tw(960172);
long long rnd(long long x, long long y) {
  static uniform_int_distribution<long long> d;
  return d(tw) % (y - x + 1) + x;
}
int main() {
  cerr << fixed << setprecision(15);
  cout << fixed << setprecision(15);
  int n, t;
  scanf("%d%d", &n, &t);
  --t;
  vector<int> inp;
  for (int i = 0; i < n; ++i) {
    int num;
    scanf("%d", &num);
    inp.push_back(num);
  }
  map<int, int> amount;
  int cur = 0;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (i + 1 > t) {
      break;
    }
    int wait = t - i - 1;
    if (wait + i + 1 >= inp[i]) {
      ++cur;
      amount[wait - (wait + i + 1 - inp[i])]++;
    }
    ans = max(ans, cur);
    cur -= amount[wait];
  }
  cout << ans << "\n";
  return 0;
}
