#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
void pruneSet(set<ll> &bowls, ll T, ll t) {
  ll maxPos = T - 1 - t;
  ({
    if (0) cerr << "TR: " << ("maxPos") << " = " << (maxPos) << endl;
  });
  while (ll((bowls).size()) && *bowls.rbegin() >= maxPos) {
    bowls.erase(*bowls.rbegin());
  }
}
int main() {
  cin.sync_with_stdio(false);
  ll n, T;
  cin >> n >> T;
  vl times(n);
  for (ll i = (0); i < (n); i++) cin >> times[i];
  for (ll i = (0); i < (n); i++) {
    times[i] -= i + 1;
  }
  set<ll> bowls;
  vector<pll> todo;
  for (ll i = (0); i < (n); i++) {
    todo.push_back({times[i], i});
  }
  sort(begin(todo), end(todo));
  pruneSet(bowls, T, 0);
  ll ans = ll((bowls).size());
  ({
    if (0) cerr << "TR: " << ("ans") << " = " << (ans) << endl;
  });
  for (ll i = (0); i < (ll((todo).size())); i++) {
    ll t = max(0ll, todo[i].first);
    bowls.insert(todo[i].second);
    pruneSet(bowls, T, t);
    ans = max(ans, ll((bowls).size()));
    ({
      if (0) cerr << "TR: " << ("i") << " = " << (i) << endl;
    });
    ({
      if (0) cerr << "TR: " << ("ans") << " = " << (ans) << endl;
    });
  }
  cout << ans << endl;
  return 0;
}
