w = int(input()) n = int(input()) s = 0 for _ in range(n): x, y = map(int, input().split()) s += x * y print(s // w)