#include using namespace std; using ll = long long; using pll = pair; #define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define all(a) (a).begin(), (a).end() #define pb push_back #define fi first #define se second const ll MOD = 1000000007; const ll MOD2 = 998244353; const ll INF = 1LL << 60; const ll N_MAX = 2e5; int main(){ ll n, m; cin >> n >> m; vector x(m), y(m); rep(i, m){ cin >> x[i] >> y[i]; x[i]--; y[i]--; } vector rx(m), ry(m); rep(i, m){ rx[i] = x[i] + y[i]; ry[i] = x[i] - y[i]; } sort(all(rx)); sort(all(ry)); rx.erase(unique(all(rx)), rx.end()); ry.erase(unique(all(ry)), ry.end()); ll ans = 0; rep(i, (ll)rx.size()){ if(rx[i] <= n-1){ ans += (rx[i]+1); }else{ ans += 2*n - rx[i] - 1; } } vector odd, even; rep(i, (ll)rx.size()){ if(rx[i]%2 == 0) even.pb(rx[i]); else odd.pb(rx[i]); } rep(i, (ll)ry.size()){ if(ry[i]%2 == 0){ ans += n - abs(ry[i]); auto itr1 = lower_bound(all(even), abs(ry[i])); ll cnt1 = 0; if(itr1 != even.begin()){ itr1--; cnt1 = itr1 - even.begin() + 1; } auto itr2 = upper_bound(all(even), 2*n-2-abs(ry[i])); ll cnt2 = even.end() - itr2; ans -= (ll)even.size() - (cnt1 + cnt2); }else{ ans += n - abs(ry[i]); auto itr1 = lower_bound(all(odd), abs(ry[i])); ll cnt1 = 0; if(itr1 != odd.begin()){ itr1--; cnt1 = itr1 - odd.begin() + 1; } auto itr2 = upper_bound(all(odd), 2*n-2-abs(ry[i])); ll cnt2 = odd.end() - itr2; ans -= (ll)odd.size() - (cnt1 + cnt2); } } cout << ans << endl; }