#include #include #include #include #include using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} ll f(ll N,ll x,ll y){ return max(0LL,min(N-x,N-y)-max(1-x,1-y)+1); } ll g(ll N,ll x,ll y){ return max(0LL,min(N-x,y-1)-max(1-x,y-N)+1); } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll N; int M; cin>>N>>M; vectorX(M),Y(M); ll ans=0; setsf,sg; vector>vf(2),vg(2); rep(i,M){ cin>>X[i]>>Y[i]; ll z=X[i]+Y[i]; if(!sf.count(X[i]-Y[i])){ sf.insert(X[i]-Y[i]); vf[z%2].push_back(X[i]-Y[i]); ans+=f(N,X[i],Y[i]); } if(!sg.count(X[i]+Y[i])){ sg.insert(X[i]+Y[i]); vg[z%2].push_back(X[i]+Y[i]); ans+=g(N,X[i],Y[i]); } } rep(t,2){ sort(all(vf[t])); sort(all(vg[t])); int l=vf[t].size(); rep(i,l){ ll l=2+abs(vf[t][i]),r=2*N-abs(vf[t][i]); ans-=lower_bound(all(vg[t]),r+1)-lower_bound(all(vg[t]),l); } } cout<