#include #include #include #include #define rep(i, l, n) for (int i = (l); i < (n); i++) #define itrep(itr, st) for(auto itr = st.begin(); itr != st.end(); itr++) #define all(x) x.begin(), x.end() #define lb(x, t) lower_bound(all(x), t) #define ub(x, t) upper_bound(all(x), t) using namespace std; using ll = long long; template using V = vector; template using VV = V >; int main(void) { ll n, m; cin >> n >> m; set xst = {}, yst = {}; rep(i, 0, m) { ll X, Y; cin >> X >> Y; X--; Y--; xst.insert(X + Y); yst.insert(X - Y); } VV xv(2, V({})); VV yv(2, V({})); itrep(itr, xst) { ll x = *itr; xv[abs(x) & 1].push_back(x); } itrep(itr, yst) { ll y = *itr; yv[abs(y) & 1].push_back(y); } ll num = 0, dc = 0; itrep(itr, xst) { ll x = *itr; int b = abs(x) & 1; num += min(x, n - 1) - max(-n + 1 + x, (ll)0) + 1; auto itr1 = lb(yv[b], max(-x, x - 2 * (n - 1))); auto itr2 = ub(yv[b], min(2 * (n - 1) - x, x)); dc += itr2 - itr1; } itrep(itr, yst) { ll y = *itr; int b = abs(y) & 1; num += min(n - 1 + y, n - 1) - max(y, (ll)0) + 1; auto itr1 = lb(xv[b], max(y, -y)); auto itr2 = ub(xv[b], min(2 * (n - 1) - y, 2 * (n - 1) + y)); dc += itr2 - itr1; } ll ans = num - dc / 2; cout << ans << endl; return 0; }