python3 代码
n, w = map(int, input().split())
p1, p2 = map(int, input().split())
p = p1 + p2
dp = [0] * (w + 1)
for i in range(n):
e, y = map(int, input().split())
for j in range(w, y-1, -1):
if e <= p:
dp[j] = max(dp[j], dp[j-y]+1)
print(dp[w])