#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long n, m, sz = 0;
set<long long> unvisited;
set<long long> g[N];
vector<long long> v;
void dfs(long long u) {
  sz++;
  unvisited.erase(u);
  vector<long long> next;
  for (auto &it : unvisited) {
    if (g[u].find(it) == g[u].end()) next.push_back(it);
  }
  for (auto &it : next) unvisited.erase(it);
  for (auto &it : next) dfs(it);
}
int32_t main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) unvisited.insert(i);
  for (long long i = 1; i <= m; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].insert(v);
    g[v].insert(u);
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (unvisited.find(i) != unvisited.end()) {
      ans++;
      sz = 0;
      dfs(i);
    }
  }
  cout << ans - 1;
  return 0;
}
