#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, T;
  cin >> n >> T;
  vector<int> t(n);
  for (int i = 0; i < n; ++i) {
    cin >> t[i];
  }
  vector<pair<int, int>> segment;
  for (int i = 0; i < n; ++i) {
    int a = max(t[i] - i, 1);
    int b = T - i - 1;
    if (a <= b) {
      segment.push_back({a, b});
    }
  }
  sort(segment.begin(), segment.end());
  set<pair<int, int>> cur_segment_set;
  int ans = 0;
  for (int i = 0; i < segment.size();) {
    int j = i;
    while ((j < segment.size()) && (segment[j].first == segment[i].first)) {
      cur_segment_set.insert({segment[j].second, segment[j].first});
      ++j;
    }
    while (cur_segment_set.begin()->first < segment[i].first) {
      cur_segment_set.erase(cur_segment_set.begin());
    }
    ans = max(ans, (int)cur_segment_set.size());
    i = j;
  }
  cout << ans << endl;
}
