#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
ll n,m;

int main(){
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>n>>m;
	bool flag=true;
	for(int i=1;i<=m;i++){
		ll u,v;
		cin>>u>>v;
		if(!(u==i&&v==i+1||u==i+1&&v==i)){
			flag=false;
		}
	}
	cout<<n*n+1;
}