h, w = map(int, input().split())
area = 0
carpets = []
while True:
   try:
       n, m = map(int, input().split())
       carpets.append((n, m))
   except EOFError:
       break
carpets.sort(key=lambda x: -x[0] * x[1])
for n, m in carpets:
   if n <= h and m <= w:
       area += n * m
       h = n
       w = m
print(area)