// Arup Guha
// 6/3/2026
// TLE for Downtime (Kattis Problem)
// https://open.kattis.com/problems/downtime

using namespace std;
#include <bits/stdc++.h>

int main() {

    // Read in request times.
    int n, k;
    cin >> n >> k;
    vector<int> times(n);
    for (int i=0; i<n; i++)
        cin >> times[i];

    // Idea here is to try all subarrays.
    int res = 0;
    for (int i=0; i<n; i++) {
        for (int j=i; j<n; j++) {
            
           // If this difference is <1000, it's a subarray to consider.
            if (times[j]-times[i]<1000)

                // This is ceiling of (j-i) divided by k.
                res = max(res, (j-i+1+k-1)/k );
        }
    }

    cout << res << endl;

    return 0;
}
