#include <bits/stdc++.h>
using namespace std;
int t[200005];
struct node {
  int pos, w;
} p[200005];
bool init[200005];
bool cmp(node a, node b) { return a.w < b.w; }
int main() {
  int n, T;
  scanf("%d%d", &n, &T);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &t[i]);
    p[i].w = t[i] - i;
    p[i].pos = i;
    t[i] = t[i] - i;
  }
  sort(p + 1, p + 1 + n, cmp);
  int wait = 0;
  int i = 1;
  int j = n;
  int tot = 0;
  memset(init, false, sizeof(init));
  while (true) {
    while (p[i].w <= wait && i <= n) {
      if (p[i].pos + wait < T) {
        tot++;
        init[p[i].pos] = true;
      }
      i++;
    }
    while (j + wait >= T && j >= 1) {
      if (init[j]) {
        tot--;
        init[j] = false;
      }
      j--;
    }
    ans = max(ans, tot);
    wait = p[i].w;
    if (i == n + 1) break;
  }
  printf("%d", ans);
}
