#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int t[N];
int pen[N];
void update(int ind, int val) {
  while (ind < N) {
    pen[ind] += val;
    ind += ind & (-ind);
  }
}
int query(int ind) {
  int ret = 0;
  while (ind > 0) {
    ret += pen[ind];
    ind = ind & (ind - 1);
  }
  return ret;
}
pair<int, int> in[N];
void solve() {
  int n, T;
  scanf("%d %d ", &n, &T);
  for (int i = 1; i <= n; ++i) {
    scanf("%d ", &t[i]);
    t[i] = max(t[i], i);
    in[i] = make_pair(t[i] - i, i);
  }
  sort(in + 1, in + n + 1);
  int ret = 0;
  for (int i = 1; i <= n; ++i) {
    int ind = in[i].second;
    update(ind, 1);
    int x = max(0, T - 1 - in[i].first);
    x = min(x, n);
    ret = max(ret, query(x));
  }
  printf("%d\n", ret);
}
int main() {
  solve();
  return 0;
}
