#include <bits/stdc++.h>
using namespace std;
struct node {
  long long int x;
  long long int y;
  long long int cnt;
  node* l;
  node* r;
  node(long long int _x, long long int _y) {
    x = _x;
    y = _y;
    l = nullptr;
    r = nullptr;
    cnt = 0;
  }
};
typedef node* pnode;
pnode treap;
long long int cnt(pnode t) { return t ? t->cnt : 0; }
void upd_cnt(pnode t) {
  if (t) t->cnt = 1 + cnt(t->r) + cnt(t->l);
}
void split(pnode t, long long int x, pnode& l, pnode& r) {
  if (!t)
    l = r = nullptr;
  else if (t->x <= x) {
    split(t->r, x, t->r, r);
    l = t;
  } else {
    split(t->l, x, l, t->l);
    r = t;
  }
  upd_cnt(t);
}
void merge(pnode t1, pnode t2, pnode& t) {
  if (!t1 || !t2) {
    t = t1 ? t1 : t2;
  } else if (t1->y > t2->y) {
    t = t1;
    merge(t->r, t2, t->r);
  } else {
    t = t2;
    merge(t1, t->l, t->l);
  }
  upd_cnt(t);
}
void insert_rec(pnode s, pnode& t) {
  if (!t) {
    t = s;
  } else if (s->y > t->y) {
    split(t, s->x, s->l, s->r);
    t = s;
  } else if (s->x < t->x) {
    insert_rec(s, t->l);
  } else {
    insert_rec(s, t->r);
  }
  upd_cnt(t);
}
void insert(long long int x) {
  long long int y = rand();
  insert_rec(new node(x, y), treap);
}
long long int count(long long int x, pnode t) {
  if (!t) return 0;
  if (t->x >= x) return count(x, t->l);
  return cnt(t->l) + 1 + count(x, t->r);
}
int main() {
  int n;
  long long int t;
  cin >> n >> t;
  treap = nullptr;
  long long int sol = 0;
  for (long long int i = 1; i <= n; ++i) {
    long long int ti;
    cin >> ti;
    insert(max(ti - i, 0LL));
    sol = max(sol, count(t - i, treap));
  }
  cout << sol << endl;
}
