#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int a[maxn], t[maxn];
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= n - 1; i++) scanf("%d", &t[i]);
  int ans = 0, cur = 0;
  for (int last = 0; last < n && last < m - 1; last++) {
    if (t[last] <= m - 1) {
      cur++;
      int pos = last + (m - t[last]);
      if (pos < n) a[pos]++;
    }
    cur -= a[last];
    ans = max(ans, cur);
  }
  printf("%d\n", ans);
  return 0;
}
