#include <bits/stdc++.h>
using namespace std;
const long long I1 = 1e9;
const long long I2 = 1e18;
const int32_t M1 = 1e9 + 7;
const int32_t M2 = 998244353;
template <typename T, typename T1>
T maxn(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T minn(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
vector<long long int> tree[4 * 200005], a(200005);
void build(int v, int st, int en) {
  if (st == en) {
    tree[v].push_back(a[st]);
  } else {
    int mid = (st + en) / 2;
    build(2 * v, st, mid);
    build(2 * v + 1, mid + 1, en);
    merge(tree[2 * v].begin(), tree[2 * v].end(), tree[2 * v + 1].begin(),
          tree[2 * v + 1].end(), back_inserter(tree[v]));
  }
}
long long int query1(int v, int st, int en, int l, int r, int i) {
  if (r < st || l > en || l > r) return 0;
  if (l <= st && r >= en)
    return (upper_bound(tree[v].begin(), tree[v].end(), i) - tree[v].begin());
  int mid = (st + en) / 2;
  return query1(2 * v, st, mid, l, r, i) +
         query1(2 * v + 1, mid + 1, en, l, r, i);
}
void solve() {
  long long int n, t, ans = 0;
  cin >> n >> t;
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] -= (i - 1);
  }
  build(1, 1, n);
  int ind = min(t - 1, n);
  for (long long int i = ind; i > 0; i--) {
    maxn(ans, query1(1, 1, n, 1, i, t - i));
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int testcase = 1;
  while (testcase--) solve();
  return 0;
}
