// Arup Guha
// 6/3/2026
// Solution to Disasterous 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];

    int res = 0;

    // i is start of range, j is end.
    int j = 0;
    for (int i=0; i<n; i++) {

        // Move j to end of range.
        while (j<n && times[j]-times[i]<1000) j++;

        // j is exclusive, so we just want ceiling of (j-i) divided by k.
        res = max(res, (j-i+k-1)/k);
    }

    cout << res << endl;

    return 0;
}
