#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n,k,x,y;
unordered_set<LL> X,Y;
int main(){
scanf("%d%d",&n,&k);
while(k--){
scanf("%d%d",&x,&y);
X.insert(x);
Y.insert(y);
}
LL cntx=X.size(),cnty=Y.size();
printf("%lld",n*n-(n-cntx)*(n-cnty));
return 0;
}