#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int mod = 1e9 + 7;
set<int> g[100003], lef;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int i, j, a, b, sz = 0;
  for (i = 1; i <= m; ++i) cin >> a >> b, g[a].insert(b), g[b].insert(a);
  for (i = 1; i <= n; ++i) lef.insert(i);
  vector<int> v;
  for (i = 1; i <= n; ++i) {
    if (lef.count(i)) {
      ++sz;
      queue<int> q;
      q.push(i);
      lef.erase(i);
      while (!q.empty()) {
        j = q.front();
        q.pop();
        v.clear();
        for (auto it : lef)
          if (!g[j].count(it)) v.push_back(it);
        for (auto it : v) q.push(it), lef.erase(it);
      }
    }
  }
  cout << sz - 1;
  return 0;
}
