#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T POW(T B, T P) {
  if (P == 0) return 1;
  if (P & 1)
    return B * POW(B, P - 1);
  else
    return SQR(POW(B, P / 2));
}
template <typename T>
inline T ModInv(T b, T m) {
  return BigMod(b, m - 2, m);
}
template <typename T>
inline T ABS(T a) {
  if (a < 0)
    return -a;
  else
    return a;
}
template <typename T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <typename T>
inline T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <class T>
inline T BMOD(T p, T e, T m) {
  T ret = 1;
  while (e) {
    if (e & 1) ret = (ret * p) % m;
    p = (p * p) % m;
    e >>= 1;
  }
  return (T)ret;
}
int n, T;
int wt[200005], bit[200005];
set<pair<int, int> > st;
void update(int pos) {
  while (pos < 200001) {
    bit[pos] += 1;
    pos += (pos & -pos);
  }
  return;
}
int query(int pos) {
  int sum = 0;
  while (pos > 0) {
    sum += bit[pos];
    pos -= (pos & -pos);
  }
  return sum;
}
int main() {
  scanf("%d%d", &n, &T);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &wt[i]);
    st.insert(make_pair(wt[i] - i, i));
  }
  int ans = 0;
  for (auto &i : st) {
    int xx = i.first;
    int yy = i.second;
    update(yy);
    int rng = T - 1 - xx;
    rng = min(n, rng);
    rng = min(rng, T - 1);
    if (rng <= 0) continue;
    int id = query(rng);
    ans = max(ans, id);
  }
  printf("%d", ans), puts("");
  return 0;
}
