#include <iostream>
#include <unordered_map>
using namespace std;
typedef long long ll;
ll n,m;
inline int read(){
int x= 0,f = 1;
char ch = getchar();
while(ch<'0'||ch>'9'){
if(ch == '-'){
f = -1;
}
ch = getchar();
}
while(ch>='0'&&ch<='9'){
x = (x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x*f;
}
int main(){
n = read(),m = read();
unordered_map<ll,ll> r;
unordered_map<ll,ll> c;
ll numr = 0,numc = 0;
while(m--){
ll x,y;
x = read(),y = read();
if(r[y]==0){
numr++;
r[y]=1;
}
if(c[x]==0){
numc++;
c[x]=1;
}
}
printf("%lld",numr*n + numc*n - numc*numr);
return 0;
}