#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9 + 7;
struct node {
  long long key, sz;
  int prior;
  node *l;
  node *r;
  node(long long _key) {
    prior = rand();
    key = _key;
    sz = 1;
    l = r = 0;
  }
};
typedef node *pnode;
long long getsz(pnode now) {
  if (!now) return 0;
  return now->sz;
}
void fixsz(pnode now) {
  if (!now) return;
  now->sz = getsz(now->l) + getsz(now->r) + 1;
  return;
}
void split(pnode now, long long key, pnode &l, pnode &r) {
  if (!now) {
    l = r = 0;
  } else if (now->key <= key) {
    split(now->r, key, now->r, r), l = now;
  } else {
    split(now->l, key, l, now->l), r = now;
  }
  fixsz(now);
}
void merge(pnode &now, pnode l, pnode r) {
  if (!l) {
    now = r;
  } else if (!r) {
    now = l;
  } else if (l->prior > r->prior) {
    merge(l->r, l->r, r), now = l;
  } else {
    merge(r->l, l, r->l), now = r;
  }
  fixsz(now);
}
void insert(pnode &now, pnode it) {
  if (!now) {
    now = it;
  } else if (it->prior > now->prior) {
    split(now, it->key, it->l, it->r), now = it;
  } else if (it->key > now->key) {
    insert(now->r, it);
  } else {
    insert(now->l, it);
  }
  fixsz(now);
}
void erase(pnode &now, long long key) {
  if (!now) return;
  if (key > now->key) {
    erase(now->r, key);
  } else if (key < now->key) {
    erase(now->l, key);
  } else {
    merge(now, now->l, now->r);
  }
  fixsz(now);
}
long long cnt(pnode now, long long x) {
  if (!now) return 0;
  if (x >= now->key) {
    return getsz(now->l) + 1 + cnt(now->r, x);
  } else {
    return cnt(now->l, x);
  }
}
const int MAXN = 4e5 + 100;
pnode root;
int n;
vector<int> t;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> n >> T;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    t.push_back(x);
    insert(root, new node(x - i - 1));
  }
  long long res = 0;
  for (int i = n - 1; i >= 0; i--) {
    int awal = T - 2 - i;
    if (awal < 0) {
      erase(root, t[i] - i - 1);
      continue;
    }
    int ba;
    res = max(res, cnt(root, awal));
    erase(root, t[i] - i - 1);
  }
  cout << res << '\n';
}
