import itertools as iter import collections as coll import heapq as hq import bisect as bis from decimal import Decimal as dec from functools import cmp_to_key import math import sys #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') sys.setrecursionlimit(10 ** 6) inp = sys.stdin.readline input = lambda : inp().rstrip() getN = lambda : int(inp()) getNs = lambda : map(int, inp().split()) getList = lambda :list(map(int, inp().split())) getStrs = lambda n : [input() for _ in [0] * n] def yexit(): print("Yes"); exit(0) def nexit(): print("No"); exit(0) pi = 3.141592653589793 mod = 1000000007 MOD = 998244353 INF = 4611686018427387903 dx = [1, 0, -1, 0]; dy = [0, 1, 0, -1] """ Main Code """ n, m = getNs() pst = set([]) qst = set([]) for x, y in [getList() for _ in [0] * m]: pst.add(x + y - 2) qst.add(x - y) ans = 0 que = [coll.deque([]) for _ in [0] * 2] for p in sorted(pst): ans += min(p, n - 1) - max(0, -n + p + 1) + 1 que[p & 1].append(p) for q in qst: ans += min(n + q - 1, n - 1) - max(0, q) + 1 for q in sorted([abs(q) for q in qst]): b = q & 1 while(len(que[b]) > 0 and que[b][0] < q): que[b].popleft() while(len(que[b]) > 0 and que[b][-1] > 2 * (n - 1) - q): que[b].pop() ans -= len(que[b]) print(ans)