Загрузка данных


w = int(input())
n = int(input())
s = 0
p = 0
for _ in range(n):
  x = int(input())
  h = int(input())
  if h % 2 == 0:
    p += 1
  if h >= x + w:
    s += 1
a = (s * (s - 1)) // 2
print(a)