#include <bits/stdc++.h>
using namespace std;
int const N = 1e5 + 5;
map<int, int> c[N];
set<int> d;
int ok[N], que[N];
void bfs(int s) {
  int top = 0, bot = 1;
  que[++top] = s;
  ok[s] = 1;
  d.erase(s);
  while (bot <= top) {
    int u = que[bot];
    bot++;
    vector<int> element;
    for (int v : d) {
      if (c[u][v]) {
        continue;
      }
      que[++top] = v;
      ok[v] = 1;
      element.push_back(v);
    }
    for (int v : element) {
      d.erase(v);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    c[u][v] = c[v][u] = 1;
  }
  for (int i = 1; i <= n; i++) {
    d.insert(i);
  }
  int component = 0;
  for (int i = 1; i <= n; i++) {
    if (ok[i]) {
      continue;
    }
    bfs(i);
    component++;
  }
  cout << component - 1 << endl;
}
