import sys from collections import defaultdict def main(): N, K, X, Y = map(int, sys.stdin.readline().split()) x0 = X % K y0 = Y % K A = list(map(int, sys.stdin.readline().split())) current = defaultdict(int) current[(x0, y0)] = 0 for a in A: a_mod = a % K next_dp = defaultdict(int) for (a_prev, b_prev), score in current.items(): sum_three = (a_prev + b_prev + a_mod) % K new_score = score + (1 if sum_three == 0 else 0) # Transition 1: discard a_prev → new state (b_prev, a_mod) key = (b_prev, a_mod) if next_dp[key] < new_score: next_dp[key] = new_score # Transition 2: discard b_prev → new state (a_prev, a_mod) key = (a_prev, a_mod) if next_dp[key] < new_score: next_dp[key] = new_score # Transition 3: discard a_mod → new state (a_prev, b_prev) key = (a_prev, b_prev) if next_dp[key] < new_score: next_dp[key] = new_score current = next_dp print(max(current.values()) if current else 0) if __name__ == "__main__": main()