#include <bits/stdc++.h>
using namespace std;
class FenwickTree {
 public:
  explicit FenwickTree(int N) : F(N, 0) {}
  void Add(int i, int delta) {
    for (; i < F.size(); i = (i | (i + 1))) {
      F[i] += delta;
    }
  }
  int Sum(int i) const {
    int result = 0;
    for (; i >= 0; i = (i & (i + 1)) - 1) {
      result += F[i];
    }
    return result;
  }

 private:
  vector<int> F;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, T;
  cin >> N >> T;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    A[i] = max(0, A[i] - (i + 1));
  }
  vector<int> all = A;
  sort(all.begin(), all.end());
  all.erase(unique(all.begin(), all.end()), all.end());
  int result = 0;
  FenwickTree f_tree(all.size());
  for (int i = 0; i < N; ++i) {
    int idx = lower_bound(all.begin(), all.end(), A[i]) - all.begin();
    f_tree.Add(idx, 1);
    int start = max(-1, T - 2 - i);
    int start_idx =
        upper_bound(all.begin(), all.end(), start) - all.begin() - 1;
    result = max(result, f_tree.Sum(start_idx));
  }
  cout << result << '\n';
  return 0;
}
