import sys input=sys.stdin.readline n, k, X, Y = map(int, input().split()) dp = [[-1e9] * k for _ in range(k)] a = list(map(int, input().split())) for i in range(n): a[i] %= k X %= k Y %= k mx = [-1e9] * k mx[X] = mx[Y] = 0 dp[X][Y] = 0 dp[Y][X] = 0 for i in range(n): x = a[i] for j in range(k): l = (k - (j + x) % k) % k dp[j][l] += 1 if dp[j][l] > mx[j]: mx[j] = dp[j][l] if dp[j][l] > mx[l]: mx[l] = dp[j][l] for j in range(k): if dp[j][x] < mx[j]: dp[j][x] = mx[j] if dp[x][j] < mx[j]: dp[x][j] = mx[j] ans = 0 for i in range(k): for j in range(k): if ans < dp[i][j]: ans = dp[i][j] print(ans)