#include using namespace std; void chmax(int& x, const int y) { x = max(x, y); } int n, k, x, y, res; int main() { cin >> n >> k >> x >> y; x %= k, y %= k; vector a(n, 0); for(auto& v : a) cin >> v, v %= k; map, int> dp; dp[{x, y}] = 0; for(const auto& v : a) { map, int> ndp; for(const auto& [key, val] : dp) { const auto [z, w] = key; int nxt = val + (v + z + w == 0 or v + z + w == k or v + z + w == 2 * k); chmax(ndp[{v, w}], nxt); chmax(ndp[{v, z}], nxt); chmax(ndp[{z, w}], nxt); } dp = ndp; } for(const auto& [key, val] : dp) chmax(res, val); cout << res << '\n'; }