#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, T, ans;
int t[N];
priority_queue<int> pq;
int main() {
  scanf("%d%d", &n, &T);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &t[i]);
    t[i] = t[i] > i ? t[i] - i : 0;
  }
  for (int i = 1; i <= n; ++i) {
    pq.push(t[i]);
    while ((long long)pq.top() + i >= T && !pq.empty()) {
      pq.pop();
    }
    ans = max(ans, (int)pq.size());
  }
  printf("%d\n", ans);
  return 0;
}
