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