#include <bits/stdc++.h>
using namespace std;
int const maxn = 1e5 + 10;
int n, m, a, b;
vector<int> g[maxn];
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int comp = 0;
  set<int> rest;
  for (int i = 1; i <= n; i++) {
    sort(g[i].begin(), g[i].end());
    rest.insert(i);
  }
  for (int i = 1; i <= n; i++) {
    if (!rest.count(i)) continue;
    rest.erase(i);
    comp++;
    queue<int> Q;
    Q.push(i);
    while (Q.size()) {
      int u = Q.front();
      Q.pop();
      vector<int> nbh(rest.size());
      auto it = set_difference(rest.begin(), rest.end(), g[u].begin(),
                               g[u].end(), nbh.begin());
      nbh.resize(it - nbh.begin());
      for (int v : nbh) rest.erase(v), Q.push(v);
    }
  }
  printf("%d\n", comp - 1);
  return 0;
}
