#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 6000;
vector<int> G[N];
int n, m, fa[N], sz[N], tot, cnt[N];
int get(int x) {
  if (fa[x] == x) return x;
  return fa[x] = get(fa[x]);
}
void merge(int u, int v) {
  u = get(u), v = get(v);
  if (u == v) return;
  fa[v] = u;
  sz[u] += sz[v];
}
int main() {
  scanf("%d%d", &n, &m);
  int u, v;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &u, &v);
    if (u > v) swap(u, v);
    G[v].emplace_back(u);
  }
  for (int i = 1; i <= n; ++i) fa[i] = i, sz[i] = 1;
  vector<int> res;
  res.push_back(1);
  for (int i = 2; i <= n; ++i) {
    for (auto &v : G[i]) {
      ++cnt[get(v)];
    }
    for (auto &v : res) {
      int p = get(v);
      if (cnt[p] < sz[p]) merge(p, i);
    }
    if (get(i) == i) res.push_back(i);
    for (auto &v : G[i]) {
      cnt[get(v)] = 0;
    }
  }
  vector<int> vis(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    if (fa[i] == i) ++tot;
  }
  printf("%d\n", tot - 1);
  return 0;
}
