#include <bits/stdc++.h>
using namespace std;
const int MAX = 400400;
int arr[MAX], bit[MAX], n, t;
map<int, int> mp;
void update(int idx, int val) {
  while (idx < MAX) {
    bit[idx] += val;
    idx += idx & -idx;
  }
}
int query(int idx) {
  int ret = 0;
  while (idx) {
    ret += bit[idx];
    idx -= idx & -idx;
  }
  return ret;
}
int main() {
  scanf("%d%d", &n, &t);
  n = min(n, t - 1);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", arr + i);
    arr[i] -= i;
    ++mp[arr[i]];
  }
  for (int i = 0; i <= n + 1; ++i) mp[t - i];
  int idx = 1;
  for (pair<int, int> i : mp) {
    update(idx, i.second);
    mp[i.first] = idx++;
  }
  int cur = t - n;
  int ans = query(mp[cur - 1]);
  for (int i = 1, j = n; i < n; ++i, --j) {
    update(mp[arr[j]], -1);
    ++cur;
    ans = max(ans, query(mp[cur - 1]));
  }
  printf("%d", ans);
  return 0;
}
