#include <bits/stdc++.h>
const int N = 2e5 + 10;
using namespace std;
int n, t, a[N], vis[N];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> t;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= i + 1;
  }
  set<pair<int, int> > q;
  if (t < n) {
    n = t;
  }
  for (int i = 0; i < n; i++) {
    q.insert({a[i], i});
  }
  int cur = 0, res = 0;
  int right = n;
  for (int i = max(t - n - 1, 0); i < t; i++) {
    int n_right = t - i - 1;
    while (right > n_right) {
      if (vis[right - 1]) {
        cur--;
        vis[right - 1] = false;
      }
      right--;
    }
    while (!q.empty() && q.begin()->first <= i) {
      if (q.begin()->second < right) {
        cur++;
        vis[q.begin()->second] = true;
      }
      q.erase(q.begin());
    }
    res = max(res, cur);
  }
  cout << res << endl;
  return 0;
}
