#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX;
const long long SIZE = 4e5 + 5;
const long long mod = 1e9 + 7;
set<long long> adj[SIZE];
set<long long> st;
long long n, cnt;
bool vis[SIZE];
void bfs(long long src) {
  queue<long long> q;
  long long i, u, v;
  q.push(src);
  vis[src] = 1;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    st.erase(u);
    set<long long> ss;
    for (auto it = st.begin(); it != st.end(); it++) {
      v = *it;
      if (adj[u].find(v) == adj[u].end() && !vis[v]) {
        ss.insert(v);
        q.push(v);
        vis[v] = 1;
      }
    }
    for (auto it = ss.begin(); it != ss.end(); it++) st.erase(*it);
  }
}
int main() {
  long long t = 0, m, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
  string s, s1, s2;
  scanf("%lld %lld", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%lld %lld", &x, &y);
    adj[x].insert(y);
    adj[y].insert(x);
  }
  for (i = 1; i <= n; i++) st.insert(i);
  for (i = 1; i <= n; i++) {
    if (!vis[i]) {
      cnt++;
      bfs(i);
    }
  }
  cnt--;
  printf("%lld\n", cnt);
  return 0;
}
