#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
/*int t;
cin >> t;
while (t--){*/
ll n, k, x, mx = 0;
cin >> n >> k >> x;
x += 1;
vector<ll> a(n), pre(n);
for (int i = 0; i < n; i++) cin >> a[i];
ll l = 0, r = 0, f = 0;
while (r < n){
if (a[r] % x == 0){
if (f == 0){
l = r;
f = 1;
}
mx = max(mx, r - l + 1);//cout<<r<<' '<<l<<endl;
r++;//cout<<mx<<' ';
} else if (x - (a[r] % x) <= k){
if (f == 0){
l = r, f = 1;
}
pre[r] += (x - (a[r] % x));
k -= (x - (a[r] % x));//cout<<r<<' '<<l<<endl;
mx = max(mx, r - l + 1);
r++;//cout<<mx<<' ';
} else {
f = 0;
k += pre[l];
l++;
}//cout<<mx<<' ';
if (l > r) r++;
}
cout << mx << endl;
//}
}