#include <bits/stdc++.h>
using namespace std;
set<pair<long long, long long> > edges;
set<long long> s;
bool ex(long long a, long long b) {
  if (a > b) swap(a, b);
  return edges.count(make_pair(a, b));
}
void bfs(long long v) {
  queue<long long> q;
  q.push(v);
  s.erase(v);
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    vector<long long> to;
    for (auto v : s) {
      if (ex(u, v)) continue;
      to.push_back(v);
    }
    for (auto v : to) {
      s.erase(v);
      q.push(v);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, u, v;
  scanf("%lld", &n);
  scanf("%lld", &m);
  while (m--) {
    scanf("%lld", &u);
    scanf("%lld", &v);
    u--;
    v--;
    if (u > v) swap(u, v);
    edges.insert(make_pair(u, v));
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) s.insert(i);
  for (long long i = 0; i < n; i++) {
    if (s.count(i)) {
      bfs(i);
      ans++;
    }
  }
  printf("%lld", ans - 1);
  return 0;
}
