#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m, ans = 0;
set<int> g[N], curSet;
bool visited[N];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    g[u].insert(v);
    g[v].insert(u);
  }
  for (int i = 1; i <= n; i++) curSet.insert(i);
  while (!curSet.empty()) {
    queue<int> q;
    int s = *curSet.begin();
    q.push(s);
    visited[s] = true;
    ans++;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (auto it : curSet) {
        if (visited[it] || g[u].find(it) != g[u].end()) continue;
        visited[it] = true;
        q.push(it);
      }
      set<int> nextSet;
      for (auto it : curSet)
        if (!visited[it]) nextSet.insert(it);
      nextSet.swap(curSet);
    }
  }
  printf("%d", ans - 1);
  return 0;
}
