#include <bits/stdc++.h>
using namespace std;
long long n, t[200005], tot;
vector<pair<long long, long long> > ord;
int main() {
  ios_base::sync_with_stdio(false);
  long long precision = numeric_limits<double>::digits10;
  cin >> n >> tot;
  for (long long i = 1; i <= n; i++) {
    cin >> t[i];
    long long l = max(t[i] - i, 0ll);
    long long r = tot - i - 1;
    if (r >= 0 && l <= r) {
      ord.push_back(make_pair(l, 1));
      ord.push_back(make_pair(r + 1, -1));
    }
  }
  sort(ord.begin(), ord.end());
  long long MAX = 0, cnt = 0;
  for (long long i = 0; i < ord.size(); i++) {
    cnt += ord[i].second;
    MAX = max(MAX, cnt);
  }
  cout << MAX << endl;
}
