#include <bits/stdc++.h>
using namespace std;
string alpha = "abcdefghijklmnopqrstuvwxyz";
const long long mod = 1e9 + 7;
const long long inf = 2e18 + 5;
const long long nax = 101010;
set<pair<long long, long long> > forbidden;
set<long long> all;
void dfs(long long u) {
  all.erase(u);
  auto it = all.begin();
  while (it != all.end()) {
    long long v = *it;
    if (!forbidden.count({u, v})) {
      dfs(v);
      it = all.begin();
    } else {
      it++;
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = (0); i < (m); i++) {
    long long u, v;
    cin >> u >> v;
    forbidden.insert({u, v});
    forbidden.insert({v, u});
  }
  for (long long i = (1); i < (n + 1); i++) all.insert(i);
  long long res = 0;
  while (!all.empty()) {
    long long u = *all.begin();
    dfs(u);
    res++;
  }
  cout << res - 1;
  return 0;
}
