http://codeforces.com/contest/1243/problem/D
#include <bits/stdc++.h>
//#include <queue>
//#include <cmath>
//#include <iostream>
//#include <unordered_map>
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(x) ((x)&(-x))
#define mem(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define INF 0x3f3f3f3f
#define ll long long
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int mod=1e9+7;
const int N=1e5+9;
set<int>g[N],s;
int n,m;
bool vis[N];
void bfs(int u)
{
queue<int>q;
q.push(u);
s.erase(u);
while(!q.empty())
{
int from=q.front();
q.pop();
if(vis[from]) continue;
vis[from]=1;
vector<int>vec;
for(auto v:s)
{
if(g[from].find(v)==g[from].end())
{
q.push(v);
vec.pb(v);
}
}
for(auto &x:vec) s.erase(x);
}
}
int main()
{
FAST_IO;
//freopen("input.txt","r",stdin);
cin>>n>>m;
for(int i=1;i<=n;i++) s.insert(i);
for(int i=1;i<=m;i++)
{
int u,v;
cin>>u>>v;
g[u].insert(v);
g[v].insert(u);
}
int ans=0;
for(int i=1;i<=n;i++)
{
if(!vis[i])
{
ans++;
bfs(i);
}
}
cout<<ans-1<<endl;
return 0;
}