#include <bits/stdc++.h>   using namespace std;   const int N = 200100;   const long long inf = 1e8;   long long bit[N];   void up(int x) {     while (x < N) {       bit[x]++;       x += (x & -x);     }   }   int query(int x) {     int sum = 0;     while (x) {       sum += bit[x];       x -= (x & -x);     }     return sum;   }   pair<int, int> a[N];   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, t;     cin >> n >> t;     for (int i = 0; i < n; ++i) {       cin >> a[i].first;       a[i].first -= i + 1;       a[i].second = i + 1;     }     sort(a, a + n);     int ans = 0;     for (int i = 0; i < n; ++i) {       up(a[i].second);       if (a[i].first < 0 && t > 1) ans = max(ans, query(min(t - 1, n)));       if (a[i].first + 1 < t && a[i].first >= 0)         ans = max(ans, query(min(t - a[i].first - 1, n)));     }     cout << ans <<   n ;     return 0;   }   