#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
int N, M;
set<int> to[MAXN + 1];
void solve() {
  int ans = 0;
  set<int> nvis;
  for (int i = 1; i <= N; i++) nvis.insert(i);
  for (int s = 1; s <= N; s++)
    if (nvis.find(s) != nvis.end()) {
      queue<int> q;
      nvis.erase(nvis.find(s));
      q.push(s);
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        set<int> tmp = nvis;
        for (int v : tmp)
          if (to[u].find(v) == to[u].end()) {
            nvis.erase(nvis.find(v));
            q.push(v);
          }
      }
      ans++;
    }
  printf("%d\n", ans - 1);
}
int main(void) {
  while (~scanf("%d%d", &N, &M)) {
    int a, b;
    for (int i = 1; i <= N; i++) to[i].clear();
    for (int i = 0; i < M; i++) {
      scanf("%d%d", &a, &b);
      to[a].insert(b);
      to[b].insert(a);
    }
    solve();
  }
  return 0;
}
