#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T& a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T& a, T b) {
  return a < b ? (a = b, true) : false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  set<int> g[N];
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].insert(b);
    g[b].insert(a);
  }
  set<int> unvisited;
  for (int i = 0; i < N; ++i) unvisited.insert(i);
  function<int(int)> dfs = [&](int u) {
    unvisited.erase(u);
    int size = 1;
    int x = 0;
    while (1) {
      auto it = unvisited.upper_bound(x);
      if (it == unvisited.end()) break;
      x = *it;
      if (g[u].count(x)) continue;
      size += dfs(x);
    }
    return size;
  };
  int no_comp = 0;
  for (int i = 0; i < N; ++i) {
    if (unvisited.count(i)) {
      ++no_comp;
      dfs(i);
    }
  }
  assert(no_comp >= 1);
  cout << no_comp - 1 << '\n';
}
