#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, X;
long long K;
cin >> N >> K >> X;
vector<int> A(N);
for (int i = 0; i < N; i++){
cin >> A[i];
}
// Choose candidate divisors d. Since A[i] <= 100 and X <= 100,
// if X < 100, try d from X+1 to 100.
// If X == 100, then d must be > 100; in that case we try d = 101.
int d_low = X + 1;
int d_high = (X < 100 ? 100 : 101);
int ans = 0;
// Try each candidate divisor d.
for (int d = d_low; d <= d_high; d++){
// Build cost array: cost[i] is the operations needed to make A[i] divisible by d.
vector<int> cost(N, 0);
for (int i = 0; i < N; i++){
int r = A[i] % d;
// if already divisible, cost is 0; otherwise cost is (d - r)
cost[i] = (r == 0 ? 0 : d - r);
}
// Use two pointers (sliding window) to find the longest subarray with total cost <= K.
long long currentSum = 0;
int left = 0;
int best = 0;
for (int right = 0; right < N; right++){
currentSum += cost[right];
// Shrink window while cost sum exceeds K.
while(currentSum > K && left <= right){
currentSum -= cost[left];
left++;
}
best = max(best, right - left + 1);
}
ans = max(ans, best);
}
cout << ans << "\n";
return 0;
}