n = int(inputO)
items = []
for - in range(n):
items . append(List(map(int, input(.splitC))))
s = int(inputO)
items. sort(key=lambda x: [0] / x[1], reverse=True)
ans = 0
for w, c in items:
if s <= 0: break
count = s // c
if count > 0:
ans += count * w
s -= count * c
print(ans)