#include #include #include #include #include using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; using modint = atcoder::static_modint<998244353>; i64 solveEdge(i64 N, vector& X, vector& Y){ sort(Y.begin(), Y.end()); i64 ans = 0; for(auto x : X){ auto itr = lower_bound(Y.begin(), Y.end(), N-1-x); ans += (i64)(itr - Y.begin()); } return ans; } int main(){ i64 N; cin >> N; int M; cin >> M; vector X[2]; vector Y[2]; rep(i,M){ i64 x; cin >> x; x--; i64 y; cin >> y; y--; X[(x+y+N)%2].push_back(x + y); Y[(x+y+N)%2].push_back(N - 1 + x - y); } rep(t,2){ sort(X[t].begin(), X[t].end()); X[t].erase(unique(X[t].begin(), X[t].end()), X[t].end()); } rep(t,2){ sort(Y[t].begin(), Y[t].end()); Y[t].erase(unique(Y[t].begin(), Y[t].end()), Y[t].end()); } i64 ans = 0; rep(t,2){ for(i64 x : X[t]) ans += N - abs(N-1-x); for(i64 x : Y[t]) ans += N - abs(N-1-x); ans -= (i64)X[t].size() * Y[t].size(); } rep(t,2){ rep(s,4){ ans += solveEdge(N, X[t], Y[t]); swap(X[t], Y[t]); for(auto& x : X[t]) x = 2*N-2-x; } } cout << ans << '\n'; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;