#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    
    int i = 0, j = 0, ans = 0;
    while (j < n) {
        // Since the array is sorted, calculate the difference directly
        if (arr[j] - arr[i] <= k) {
            ans = max(ans, j - i + 1); // Update the maximum length
            j++; // Expand the window
        } else {
            i++; // Shrink the window
        }
    }
    
    cout << ans;
    return 0;
}
