#include <bits/stdc++.h>
using namespace std;
priority_queue<int> Q;
int main() {
  int n, T;
  scanf("%d%d", &n, &T);
  int ans = 0;
  for (int i = (1); i < (min(T, n + 1)); ++i) {
    while (!Q.empty() && Q.top() >= T - i) Q.pop();
    int x;
    scanf("%d", &x);
    if (x < T) Q.push(x - i);
    ans = max(ans, ((int)(Q).size()));
  }
  cout << ans << "\n";
}
