#include <bits/stdc++.h>
using namespace std;
set<long long> unvis;
set<long long> adj[100005];
long long n, m;
void dfs(long long curr) {
  vector<long long> next;
  for (auto V : unvis) {
    if (adj[curr].find((V)) == adj[curr].end()) {
      next.push_back(V);
    }
  }
  for (long long V : next) {
    unvis.erase(V);
  }
  for (long long V : next) {
    dfs(V);
  }
}
void solve() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    adj[x].insert(y);
    adj[y].insert(x);
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) unvis.insert(i);
  for (long long i = 1; i <= n; i++) {
    if (unvis.find(i) != unvis.end()) {
      ans++;
      unvis.erase(i);
      dfs(i);
    }
  }
  cout << ans - 1 << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
