#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
const int N = 1e5 + 7;
const int M = 1e6 + 7;
const int INF = 1e9 + 8;
set<int> G[M], s;
int vis[M];
void bfs(int x) {
  queue<int> q;
  q.push(x);
  s.erase(x);
  while (q.size()) {
    int y = q.front();
    q.pop();
    if (vis[y]) continue;
    vis[y] = 1;
    for (auto it = s.begin(); it != s.end();) {
      int v = *it;
      ++it;
      if (G[y].find(v) == G[y].end()) {
        q.push(v);
        s.erase(v);
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int u, v;
  for (int i = 1; i <= n; i++) s.insert(i);
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    G[u].insert(v);
    G[v].insert(u);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      bfs(i);
      ans++;
    }
  }
  cout << ans - 1 << endl;
  return 0;
}
