#include <bits/stdc++.h>
using namespace std;
set<int> st, vc[100005];
int vis[100005];
void bfs(int x) {
  queue<int> que, vg;
  que.push(x);
  st.erase(x);
  while (que.size()) {
    int x = que.front();
    que.pop();
    vis[x] = 1;
    for (auto it = st.begin(); it != st.end(); it++) {
      int v = *it;
      if (vc[x].find(v) == vc[x].end()) {
        que.push(v);
        vg.push(v);
      }
    }
    while (vg.size()) {
      int v = vg.front();
      st.erase(v);
      vg.pop();
    }
  }
}
int main() {
  int n, m, u, v;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) st.insert(i);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    vc[u].insert(v);
    vc[v].insert(u);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      bfs(i);
      ans++;
    }
  }
  printf("%d\n", ans - 1);
  return 0;
}
