N, K, x, y = map(int, input().split()) A = list(map(lambda x: int(x) % K, input().split())) x %= K y %= K # dp[i,j]: 手持ちがi,j -> 最大スコア inf = 10**5 inf = 10 dp = [[-inf] * K for _ in range(K)] memo = [-inf] * K dp[x][y] = 0 dp[y][x] = 0 memo[x] = 0 memo[y] = 0 for a in A: for x in range(K): y = (K - x - a) % K if dp[x][y] >= 0: dp[x][y] += 1 memo[x] = max(memo[x], dp[x][y]) for x in range(K): if memo[x] < 0: continue dp[x][a] = max(dp[x][a], memo[x]) dp[a][x] = max(dp[x][a], memo[x]) memo[a] = max(dp[a]) ans = 0 for i in range(K): for j in range(K): ans = max(ans, dp[i][j]) print(ans)