#include <bits/stdc++.h>
using namespace std;
const int MAX = (2e5) + 10;
struct Node {
  int key, prio, val, sum;
  Node *l, *r;
  Node(int k, int p) {
    key = k;
    prio = p;
    sum = val = 1;
    l = r = NULL;
  }
};
void update(Node *X) {
  if (X == NULL) return;
  X->sum = X->val;
  if (X->l != NULL) X->sum += X->l->sum;
  if (X->r != NULL) X->sum += X->r->sum;
  return;
}
Node *leftRotate(Node *up, Node *down) {
  up->l = down->r;
  down->r = up;
  update(down);
  update(up);
  return down;
}
Node *rightRotate(Node *up, Node *down) {
  up->r = down->l;
  down->l = up;
  update(down);
  update(up);
  return down;
}
Node *balance(Node *R) {
  if (R->l != NULL && R->l->prio < R->prio)
    return leftRotate(R, R->l);
  else if (R->r != NULL && R->r->prio < R->prio)
    return rightRotate(R, R->r);
  return R;
}
Node *add(Node *R, Node *org) {
  if (R == NULL) return org;
  if (org->key <= R->key)
    R->l = add(R->l, org);
  else
    R->r = add(R->r, org);
  R = balance(R);
  update(R);
  return R;
}
Node *meld(Node *sm, Node *bg) {
  if (sm == NULL)
    return bg;
  else if (bg == NULL)
    return sm;
  else if (sm->prio < bg->prio) {
    sm->r = meld(sm->r, bg);
    update(sm);
    return sm;
  } else {
    bg->l = meld(sm, bg->l);
    update(bg);
    return bg;
  }
}
Node *split(Node *R, int val) {
  if (R == NULL)
    return R;
  else if (R->key == val) {
    R->prio = -1;
    return R;
  } else if (R->key >= val)
    R->l = split(R->l, val);
  else
    R->r = split(R->r, val);
  R = balance(R);
  return R;
}
Node *eraseX(Node *R, int x) {
  if (R == NULL) return R;
  R = split(R, x);
  if (R->key != x)
    return R;
  else if (R->l == NULL)
    return R->r;
  else if (R->r == NULL)
    return R->l;
  else
    return meld(R->l, R->r);
}
int getSum(Node *t, int low) {
  if (t == NULL) return 0;
  if (t->key <= low) {
    int ret = t->val;
    if (t->l != NULL) ret += t->l->sum;
    return getSum(t->r, low) + ret;
  } else
    return getSum(t->l, low);
}
int main() {
  ios::sync_with_stdio(false);
  Node *R = NULL;
  int n, T;
  cin >> n >> T;
  vector<int> ara(n + 1, 0), samne;
  vector<int> need(n + 1, 0);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  vector<int> per(n);
  for (int i = 0; i < n; i++) per[i] = i;
  shuffle(per.begin(), per.end(), rng);
  for (int i = 1; i <= n; i++) {
    cin >> ara[i];
    need[i] = max(need[i], ara[i] - i);
    samne.push_back(need[i]);
    R = add(R, new Node(need[i], per[i]));
  }
  sort(samne.begin(), samne.end());
  int j = n, prin = 0;
  for (int x : samne) {
    while (j) {
      int ase = T - x;
      if (j + x >= T) {
        R = eraseX(R, need[j]);
        j--;
      } else
        break;
    }
    prin = max(prin, getSum(R, x));
  }
  cout << prin << endl;
  return 0;
}
