#include <bits/stdc++.h>
using namespace std;
long long int mod = 998244353, n, m, k, flag;
vector<set<long long int>> adj;
set<long long int> used;
void bfs(long long int u) {
  used.erase(u);
  queue<long long int> q;
  q.push(u);
  while (q.size()) {
    long long int u = q.front();
    q.pop();
    vector<long long int> v;
    for (auto x : used) {
      if (adj[u].count(x) == 0) {
        q.push(x);
        v.push_back(x);
      }
    }
    for (auto x : v) used.erase(x);
  }
}
void solve() {
  cin >> n >> m;
  adj.resize(n);
  for (long long int i = 0; i < n; i++) used.insert(i);
  for (long long int i = 0; i < m; i++) {
    long long int a, b;
    cin >> a >> b;
    a--, b--;
    adj[a].insert(b);
    adj[b].insert(a);
  }
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    if (used.count(i) == 1) {
      bfs(i);
      ans++;
    }
  }
  cout << ans - 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
