#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 7;
int n, m, ans, fa[N], size[N];
vector<int> vec[N], b;
map<int, int> mp;
int read() {
  int s = 0;
  char c = getchar(), lc = '+';
  while (c < '0' || '9' < c) lc = c, c = getchar();
  while ('0' <= c && c <= '9') s = s * 10 + c - '0', c = getchar();
  return lc == '-' ? -s : s;
}
void write(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x < 10)
    putchar(x + '0');
  else {
    write(x / 10);
    putchar(x % 10 + '0');
  }
}
void print(int x = -1, char c = '\n') {
  write(x);
  putchar(c);
}
void init() {
  for (int i = 1; i <= n; i++) fa[i] = i, size[i] = 1;
}
int find(int x) {
  if (fa[x] == x) return x;
  return fa[x] = find(fa[x]);
}
int main() {
  n = read(), m = read();
  init();
  for (int i = 1; i <= m; i++) {
    int u, v;
    u = read(), v = read();
    if (u < v) swap(u, v);
    vec[u].push_back(v);
  }
  for (int u = 1; u <= n; u++) {
    mp.clear();
    for (int i = 0; i < vec[u].size(); i++) {
      int v = vec[u][i];
      mp[find(v)]++;
    }
    for (int i = 0; i < b.size(); i++) {
      int v = b[i];
      int x = find(u), y = find(v);
      if (x == y) continue;
      if (mp[y] < size[y]) fa[x] = y, size[y] += size[x];
    }
    if (find(u) == u) b.push_back(u);
  }
  for (int i = 1; i <= n; i++)
    if (fa[i] == i) ans++;
  print(ans - 1);
  return 0;
}
