#include <bits/stdc++.h>
int p, q, r, t[200001], n, k, ans, rt, sz;
struct node {
  int v, r, lc, rc, siz;
} tree[400001];
void pushup(int x) {
  tree[x].siz = tree[tree[x].lc].siz + tree[tree[x].rc].siz + 1;
}
void split(int x, int k, int &a, int &b) {
  if (!x) {
    a = b = 0;
    return;
  }
  if (tree[x].v <= k)
    a = x, split(tree[x].rc, k, tree[x].rc, b);
  else
    b = x, split(tree[x].lc, k, a, tree[x].lc);
  pushup(x);
}
int merge(int a, int b) {
  if (!a || !b) return a | b;
  if (tree[a].r < tree[b].r) {
    tree[a].rc = merge(tree[a].rc, b);
    pushup(a);
    return a;
  }
  tree[b].lc = merge(a, tree[b].lc);
  pushup(b);
  return b;
}
int make(int v) {
  ++sz;
  tree[sz].v = v;
  tree[sz].siz = 1;
  tree[sz].r = rand();
  tree[sz].lc = tree[sz].rc = 0;
  return sz;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", t + i);
  for (int i = 1; i <= n; ++i) {
    split(rt, ((t[i] - i) > (0) ? (t[i] - i) : (0)), p, q);
    rt = merge(merge(p, make(((t[i] - i) > (0) ? (t[i] - i) : (0)))), q);
    split(rt, k - i - 1, p, q);
    ans = ((ans) > (tree[p].siz) ? (ans) : (tree[p].siz));
    rt = merge(p, q);
  }
  printf("%d\n", ans);
  return 0;
}
