list1 = input().split(' ')
list2 = input().split(' ')
n, s, a, b = int(list1[0]), int(list1[1]), int(list2[0]), int(list2[1])
listEnd, sum0 = [], 0
for i in range(n):
list0 = input().split(' ')
if a + b >= int(list0[0]):
listEnd.append(list0)
listEnd = sorted(listEnd, key=lambda x: x[1])
print(listEnd)
for j in listEnd:
s -= int(j[1])
if s >= 0:
sum0 += 1
else:
break
print(sum0)