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