#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
long long binexp(long long a, long long b, long long mod) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    b /= 2;
    a = a * a % mod;
  }
  return ans;
}
long long inverse(long long a, long long p, long long mod) {
  return binexp(a, p - 2, mod);
}
void createadj(vector<vector<long long> > &adj, long long m) {
  long long x, y;
  for (int i = 0; i < (m); ++i) {
    cin >> x >> y;
    x--, y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
}
const long long mod = 1e9 + 7;
const int maxn = 1e5 + 5;
void pre() {}
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> cnt(600005, 0);
  for (int i = 0; i < n; ++i) {
    int cur;
    cin >> cur;
    cnt[max(i - k, 0)]++;
    cnt[i + k + 1]--;
  }
  for (int i = 1; i < 600004; ++i) {
    cnt[i] = cnt[i - 1] + cnt[i];
  }
  int ans = *max_element(cnt.begin(), cnt.end());
  cout << ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int TC = 1;
  pre();
  while (TC--) {
    solve();
    cout << "\n";
  }
  return 0;
}
