#include <bits/stdc++.h>
namespace DO {
const int MAX_TREE_SIZE = 200000 * 4 + 123;
struct tNode {
  int LSon, RSon;
  int L, R;
  int cnt;
};
tNode Tree[MAX_TREE_SIZE];
int tt = 0;
int NewNode(int L, int R) {
  tt++;
  Tree[tt].L = L;
  Tree[tt].R = R;
  return tt;
}
int GetCnt(int v) {
  if (v == 0) return 0;
  return Tree[v].cnt;
}
void Modify(int v, int x, int delta) {
  if (Tree[v].L == Tree[v].R) {
    Tree[v].cnt += delta;
  } else {
    int med = (Tree[v].L + Tree[v].R) / 2;
    if (x <= med) {
      if (Tree[v].LSon == 0) Tree[v].LSon = NewNode(Tree[v].L, med);
      Modify(Tree[v].LSon, x, delta);
    } else {
      if (Tree[v].RSon == 0) Tree[v].RSon = NewNode(med + 1, Tree[v].R);
      Modify(Tree[v].RSon, x, delta);
    }
    Tree[v].cnt = GetCnt(Tree[v].LSon) + GetCnt(Tree[v].RSon);
  }
}
int getOn(int v, int LB, int RB) {
  if (LB <= Tree[v].L and Tree[v].R <= RB)
    return Tree[v].cnt;
  else {
    int med = (Tree[v].L + Tree[v].R) / 2;
    int res = 0;
    if (Tree[v].LSon > 0 and LB <= med) res += getOn(Tree[v].LSon, LB, RB);
    if (Tree[v].RSon > 0 and med + 1 <= RB) res += getOn(Tree[v].RSon, LB, RB);
    return res;
  }
}
}  // namespace DO
using namespace std;
struct tEvent {
  int time;
  int location;
  inline bool operator<(const tEvent left) const { return (time < left.time); }
};
tEvent make_event(int t, int l) {
  tEvent res;
  res.time = t;
  res.location = l;
  return res;
}
int main() {
  int n, t;
  scanf("%i %i", &n, &t);
  vector<tEvent> e;
  for (int i = 1; i <= n; i++) {
    int tmp;
    scanf("%i", &tmp);
    e.push_back(make_event(max(0, tmp - i), i));
  }
  sort(e.begin(), e.end());
  int root = DO::NewNode(1, n);
  int ans = 0;
  for (int i = 0; i < e.size(); i++) {
    DO::Modify(root, e[i].location, +1);
    if (t - e[i].time > 0) {
      int cur = DO::getOn(root, 1, t - e[i].time - 1);
      ans = max(cur, ans);
    }
  }
  printf("%i \n", ans);
}
