#include<bits/stdc++.h>
using namespace std;
using pi=pair<int,int>;
long long K(long long x){
return (x*(x-1))/2;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,m;
cin >> n >> m;
vector<pi> eg(m);
vector<int> deg(n,0);
for(auto &nx : eg){
cin >> nx.first;
cin >> nx.second;
nx.first--;
nx.second--;
deg[nx.first]++;
deg[nx.second]++;
}
vector<int> vn(n,0);
for(int i=0;i<n;i++){
vn[deg[i]]++;
}
for(int i=n-2;i>=0;i--){
vn[i]+=vn[i+1];
}
vector<int> cnt(n,0);
for(auto &nx : eg){
cnt[min(deg[nx.first],deg[nx.second])]++;
}
for(int i=n-2;i>=0;i--){
cnt[i]+=cnt[i+1];
}
int kdeg=1e9;
for(int i=0;i<n;i++){
if(cnt[i]==K(vn[i])){kdeg=i; break;}
}
if(kdeg>5e8){cout << "0\n"; return 0;}
vector<int> col(n,0);
for(int i=0;i<n;i++){
if(deg[i]>=kdeg){col[i]=1;}
}
bool jud=true;
int c11=0;
vector<int> speg(n,0);
for(auto &nx : eg){
if(col[nx.first]==1 && col[nx.second]==1){c11++;}
else if(col[nx.first]==0 && col[nx.second]==0){jud=false; break;}
else{
speg[nx.first]++;
speg[nx.second]++;
}
}
if(!jud){cout << "0\n"; return 0;}
int spsz=0;
for(auto &nx : col){spsz+=nx;}
int res=1;
for(int i=0;i<n;i++){
if(col[i]==0){
if(speg[i]==spsz){res++;}
}
else{
if(speg[i]==0){res++;}
}
}
cout << res << "\n";
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnVzaW5nIHBpPXBhaXI8aW50LGludD47Cgpsb25nIGxvbmcgSyhsb25nIGxvbmcgeCl7CiAgcmV0dXJuICh4Kih4LTEpKS8yOwp9CgppbnQgbWFpbigpewogIGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICBjaW4udGllKG51bGxwdHIpOwogIGludCBuLG07CiAgY2luID4+IG4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FtueC5zZWNvbmRdPT0wKXtqdWQ9ZmFsc2U7IGJyZWFrO30KICAgIGVsc2V7CiAgICAgIHNwZWdbbnguZmlyc3RdKys7CiAgICAgIHNwZWdbbnguc2Vjb25kXSsrOwogICAgfQogIH0KICBpZighanVkKXtjb3V0IDw8ICIwXG4iOyByZXR1cm4gMDt9CgogIGludCBzcHN6PTA7CiAgZm9yKGF1dG8gJm54IDogY29sKXtzcHN6Kz1ueDt9CgogIGludCByZXM9MTsKICBmb3IoaW50IGk9MDtpPG47aSsrKXsKICAgIGlmKGNvbFtpXT09MCl7CiAgICAgIGlmKHNwZWdbaV09PXNwc3ope3JlcysrO30KICAgIH0KICAgIGVsc2V7CiAgICAgIGlmKHNwZWdbaV09PTApe3JlcysrO30KICAgIH0KICB9CiAgY291dCA8PCByZXMgPDwgIlxuIjsKICByZXR1cm4gMDsKfQo=