#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 7;
vector<int> gr[N];
int n, m;
int cnt[N];
set<int> s;
int par[N], sz[N];
void precalc() {
  iota(par, par + N, 0);
  fill(sz, sz + N, 1);
}
int getpar(int a) {
  if (par[a] == a) return a;
  return par[a] = getpar(par[a]);
}
void unite(int a, int b) {
  a = getpar(a);
  b = getpar(b);
  if (a != b) {
    if (sz[a] > sz[b]) swap(a, b);
    par[a] = b;
    sz[b] += sz[a];
    s.erase(a);
  }
}
int main() {
  precalc();
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    if (u > v) swap(u, v);
    gr[v].push_back(u);
  }
  for (int v = 1; v <= n; v++) {
    for (int to : gr[v]) {
      cnt[getpar(to)]++;
    }
    vector<int> vec;
    for (int to : s) {
      if (sz[getpar(to)] != cnt[getpar(to)]) {
        vec.push_back(to);
      }
      cnt[getpar(to)] = 0;
    }
    for (int to : vec) {
      unite(to, v);
    }
    s.insert(getpar(v));
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (getpar(i) == i);
  }
  printf("%d\n", ans - 1);
}
