from bisect import bisect_left, bisect_right from collections import deque import sys input = sys.stdin.readline n, m = map(int, input().split()) xst = set([]); yst = set([]) for _ in [0] * m: X, Y = map(int, input().split()) xst.add((X - 1) + (Y - 1)) yst.add((X - 1) - (Y - 1)) ans = 0 xlis = [[] for _ in [0] * 2] for x in xst: ans += min(x, n - 1) - max(-n + 1 + x, 0) + 1 xlis[x & 1].append(x) for y in yst: ans += min(n - 1 + y, n - 1) - max(y, 0) + 1 que = [deque(sorted(lis)) for lis in xlis] for y in sorted(abs(y) for y in yst): lv, rv = y, 2 * (n - 1) - y b = y & 1 while(que[b] and que[b][-1] > rv): que[b].pop() while(que[b] and que[b][0] < lv): que[b].popleft() ans -= len(que[b]) print(ans)