#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int root[N], c[N * 25], ls[N * 25], rs[N * 25], tot, t[N], b[N];
void update(int &rt, int last, int l, int r, int p) {
  rt = ++tot;
  c[rt] = c[last] + 1;
  ls[rt] = ls[last];
  rs[rt] = rs[last];
  if (l == r) return;
  int m = (l + r) >> 1;
  if (p <= m)
    update(ls[rt], ls[last], l, m, p);
  else
    update(rs[rt], rs[last], m + 1, r, p);
}
int query(int rt1, int rt2, int l, int r, int v) {
  if (v >= r) return c[rt2] - c[rt1];
  int m = (l + r) >> 1;
  if (v <= m)
    return query(ls[rt1], ls[rt2], l, m, v);
  else
    return query(ls[rt1], ls[rt2], l, m, v) +
           query(rs[rt1], rs[rt2], m + 1, r, v);
}
int main() {
  int n, T, m = 0;
  scanf("%d%d", &n, &T);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &t[i]);
    b[m++] = t[i] - i;
  }
  sort(b, b + m);
  m = unique(b, b + m) - b;
  for (int i = 1; i <= n; ++i) {
    int id = lower_bound(b, b + m, t[i] - i) - b + 1;
    update(root[i], root[i - 1], 1, m, id);
  }
  int ans = 0;
  for (int i = n; i >= 1; --i) {
    if (T - i - 1 < 0) continue;
    int id = upper_bound(b, b + m, T - i - 1) - b;
    if (id > 0) ans = max(ans, query(root[0], root[i], 1, m, id));
  }
  printf("%d\n", ans);
  return 0;
}
