#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 1;
int N, M;
set<int> graph[MAX_N];
int root[MAX_N], cnt[MAX_N], U[MAX_N], V[MAX_N];
int find_root(int u) {
  while (u != root[u]) u = root[u];
  return root[u];
}
bool try_merge(int u, int v) {
  u = find_root(u);
  v = find_root(v);
  if (u != v) {
    if (cnt[u] == cnt[v]) cnt[u]++;
    if (cnt[u] > cnt[v])
      root[v] = u;
    else
      root[u] = v;
    return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> N >> M;
  for (int i = 1; i <= M; i++) {
    cin >> U[i] >> V[i];
    graph[U[i]].insert(V[i]);
    graph[V[i]].insert(U[i]);
  }
  for (int i = 1; i <= N; i++) {
    root[i] = i;
  }
  for (int u = 1; u <= N; u++) {
    for (int v = u + 1, c = 1; v <= N && c <= 20; v++) {
      if (graph[u].find(v) == graph[u].end()) {
        c++;
        try_merge(u, v);
      }
    }
  }
  set<int> components;
  for (int i = 1; i <= N; i++) components.insert(find_root(i));
  int sz = components.size();
  int mst = sz - 1;
  cout << mst;
  return 0;
}
