#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<set<int>> g(n + 1);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].insert(y);
    g[y].insert(x);
  }
  set<int> notUsed;
  for (int i = 1; i <= n; i++) {
    notUsed.insert(i);
  }
  auto bfs = [&](int s) {
    queue<int> q;
    q.push(s);
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      vector<int> toPush;
      for (int to : notUsed) {
        if (!g[v].count(to)) {
          toPush.push_back(to);
        }
      }
      for (int to : toPush) {
        notUsed.erase(to);
        q.push(to);
      }
    }
  };
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (notUsed.count(i)) {
      bfs(i);
      ans++;
    }
  }
  cout << ans - 1 << endl;
}
