#include using namespace std; const int INF = 1000000; int main(){ int N, K, X, Y; cin >> N >> K >> X >> Y; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; A[i] %= K; } vector> dp(K, vector(K, -INF)); dp[X % K][Y % K] = 0; vector r(K, -INF), c(K, -INF); r[X % K] = 0; c[Y % K] = 0; for (int i = 0; i < N; i++){ for (int j = 0; j < K; j++){ int k = (K * 2 - j - A[i]) % K; dp[j][k]++; r[j] = max(r[j], dp[j][k]); c[k] = max(c[k], dp[j][k]); } vector> T; for (int j = 0; j < K; j++){ T.push_back(make_tuple(A[i], j, r[j])); T.push_back(make_tuple(A[i], j, c[j])); } for (int j = 0; j < K * 2; j++){ int r2 = get<0>(T[j]); int c2 = get<1>(T[j]); int x = get<2>(T[j]); dp[r2][c2] = max(dp[r2][c2], x); r[r2] = max(r[r2], x); c[c2] = max(c[c2], x); } } int ans = 0; for (int i = 0; i < K; i++){ for (int j = 0; j < K; j++){ ans = max(ans, dp[i][j]); } } cout << ans << endl; }