#include using namespace std; int main(){ long long L, N; cin >> L >> N; vector> A, B; for (int i = 0; i < N; i++){ long long y, x; cin >> y >> x; y--; x--; if ((x + y) % 2 == 0){ A.push_back(make_pair(y, x)); } else { B.push_back(make_pair(y, x)); } } int Acnt = A.size(); set Ax, Ay; for (int i = 0; i < Acnt; i++){ Ay.insert(A[i].first - A[i].second); Ax.insert(A[i].first + A[i].second); } vector Ay2; for (long long y : Ay){ Ay2.push_back(y); } long long Aans = 0; for (long long x : Ax){ Aans += min(x + 1, L * 2 - x - 1); } for (long long y : Ay){ Aans += L - abs(y); } for (long long x : Ax){ long long ub = min(x, L * 2 - 2 - x); long long lb = -ub; Aans -= upper_bound(Ay2.begin(), Ay2.end(), ub) - lower_bound(Ay2.begin(), Ay2.end(), lb); } long long Bcnt = B.size(); set Bx, By; for (int i = 0; i < Bcnt; i++){ By.insert(B[i].first - B[i].second); Bx.insert(B[i].first + B[i].second); } vector By2; for (long long y : By){ By2.push_back(y); } long long Bans = 0; for (long long x : Bx){ Bans += min(x + 1, L * 2 - x - 1); } for (long long y : By){ Bans += L - abs(y); } for (long long x : Bx){ long long ub = min(x, L * 2 - 2 - x); long long lb = -ub; Bans -= upper_bound(By2.begin(), By2.end(), ub) - lower_bound(By2.begin(), By2.end(), lb); } cout << Aans + Bans << endl; }