#include <bits/stdc++.h>
using namespace std;
int n, m, u, v, ans;
set<int> E[100005], uvis;
void dfs(int x) {
  vector<int> V;
  for (auto v : uvis)
    if (!E[x].count(v)) V.push_back(v);
  for (auto &i : V) uvis.erase(i);
  for (auto &i : V) dfs(i);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) uvis.insert(i);
  for (int i = 1; i <= m; i++)
    scanf("%d%d", &u, &v), E[u].insert(v), E[v].insert(u);
  for (int i = 1; i <= n; i++)
    if (uvis.count(i)) {
      uvis.erase(i);
      dfs(i), ans++;
    }
  printf("%d", ans - 1);
  return 0;
}
