#include <bits/stdc++.h>
using namespace std;
const long long N = 100100;
long long vis[N], ans;
long long n, m;
set<int> adj[N], Zadj;
set<int>::iterator it;
queue<int> q;
void g(int u, int v) {
  adj[u].insert(v);
  adj[v].insert(u);
}
void bfs(int i) {
  q.push(i);
  Zadj.erase(i);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    for (it = Zadj.begin(); it != Zadj.end();) {
      int v = *it;
      it++;
      if (adj[u].find(v) == adj[u].end()) {
        q.push(v);
        Zadj.erase(v);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) Zadj.insert(i);
  while (m--) {
    int u, v;
    cin >> u >> v;
    g(u, v);
  }
  memset(vis, 0, sizeof vis);
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) {
      bfs(i);
      ans++;
    }
  }
  cout << ans - 1 << endl;
}
