#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1001;
vector<int> g[N];
int dfs(int v, set<int> &left) {
  set<int> newLeft, toDFS;
  for (int u : g[v])
    if (left.count(u)) newLeft.insert(u);
  for (int u : newLeft) left.erase(u);
  toDFS = left;
  left = newLeft;
  int ans = toDFS.size();
  for (int u : toDFS) ans += dfs(u, left);
  return ans;
}
int main() {
  int n, m;
  cin >> n >> m;
  while (m--) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  set<int> left;
  for (int i = 1; i <= n; i++) left.insert(i);
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (left.count(i)) {
      ans++;
      left.erase(i);
      dfs(i, left);
    }
  cout << ans - 1 << '\n';
}
