#include <bits/stdc++.h>
using namespace std;
int n, m, u, v, ans = -1, s[100001], f[100001];
vector<int> c[100001], b;
map<int, int> a;
inline long long read() {
  long long sum = 0, x = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') x = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = sum * 10 + ch - '0';
    ch = getchar();
  }
  return sum * x;
}
inline void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
  return;
}
inline int find(int x) {
  if (x == f[x]) return x;
  return f[x] = find(f[x]);
}
int main() {
  n = read();
  m = read();
  for (register int i = 1; i <= n; ++i) {
    f[i] = i;
    s[i] = 1;
  }
  for (register int i = 1; i <= m; ++i) {
    u = read();
    v = read();
    if (u < v) swap(u, v);
    c[u].push_back(v);
  }
  for (register int i = 1; i <= n; ++i) {
    a.clear();
    for (auto j : c[i]) ++a[find(j)];
    for (auto j : b) {
      int x = find(i);
      int y = find(j);
      if (x == y) continue;
      if (a[y] < s[y]) {
        f[x] = y;
        s[y] += s[x];
      }
    }
    if (find(i) == i) b.push_back(i);
  }
  for (register int i = 1; i <= n; ++i) ans += (f[i] == i);
  write(ans);
  return 0;
}
