#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int ps[MAXN];
void init_set(int sz) {
  for (int i = 0; i < sz; i++) ps[i] = i;
}
int find_set(int i) { return ps[i] == i ? i : ps[i] = find_set(ps[i]); }
bool is_same_set(int i, int j) { return find_set(i) == find_set(j); }
void unit_set(int i, int j) { ps[find_set(i)] = find_set(j); }
vector<int> adj[MAXN];
int n, lazy[4 * MAXN];
int left(int p) { return (p << 1); }
int right(int p) { return (p << 1) + 1; }
void propagate(int p, int L, int R) {
  if (lazy[p] == 0) return;
  if (L == R) {
    unit_set(L, lazy[p]);
  } else {
    if (lazy[left(p)]) {
      unit_set(lazy[left(p)], lazy[p]);
    }
    if (lazy[right(p)]) {
      unit_set(lazy[right(p)], lazy[p]);
    }
    lazy[left(p)] = lazy[right(p)] = lazy[p];
  }
  lazy[p] = 0;
}
void unit_set_range(int p, int L, int R, int i, int j, int x) {
  propagate(p, L, R);
  if (L > j or R < i) return;
  if (L >= i and R <= j) {
    lazy[p] = x;
    return;
  }
  int mid = (L + R) >> 1;
  unit_set_range(left(p), L, mid, i, j, x);
  unit_set_range(right(p), mid + 1, R, i, j, x);
}
void unit_set_range(int l, int r, int x) {
  if (l <= r) {
    unit_set_range(1, 1, n, l, r, x);
  }
}
int find_set_range(int p, int L, int R, int i) {
  propagate(p, L, R);
  if (L > i or R < i) return 0;
  if (L == R) return find_set(i);
  int mid = (L + R) >> 1;
  return find_set_range(left(p), L, mid, i) +
         find_set_range(right(p), mid + 1, R, i);
}
int find_set_range(int i) { return find_set_range(1, 1, n, i); }
int main() {
  int m;
  while (scanf("%d%d", &n, &m) > 0) {
    for (int u = 1; u <= n; u++) {
      adj[u].push_back(0);
    }
    while (m--) {
      int a, b;
      scanf("%d%d", &a, &b);
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    memset(lazy, 0, sizeof lazy);
    init_set(n + 1);
    for (int u = 1; u <= n; u++) {
      sort(adj[u].begin(), adj[u].end());
      adj[u].push_back(n + 1);
      for (int i = 0; i + 1 < adj[u].size(); i++) {
        unit_set_range(adj[u][i] + 1, adj[u][i + 1] - 1, u);
      }
    }
    for (int u = 1; u <= n; u++) {
      find_set_range(u);
    }
    set<int> unique;
    for (int u = 1; u <= n; u++) {
      unique.insert(find_set_range(u));
    }
    printf("%d\n", (int)unique.size() - 1);
    for (int u = 1; u <= n; u++) {
      adj[u].clear();
    }
  }
}
