#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 200031;
int n, t[N];
vector<pair<int, int> > events;
int ans;
int T;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> T;
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
    if (t[i] >= T) continue;
    int min_delay = t[i] - i;
    if (min_delay < 0) min_delay = 0;
    int max_delay = T - i;
    if (max_delay < min_delay) continue;
    events.push_back(make_pair(min_delay, 1));
    events.push_back(make_pair(max_delay, -1));
  }
  sort(events.begin(), events.end());
  int cur = 0;
  for (int i = 0; i < events.size(); i++) {
    cur += events[i].second;
    ans = max(ans, cur);
  }
  cout << ans << endl;
  cin.get();
  cin.get();
  return 0;
}
