#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long ksm(long long a, long long b, long long p) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % p;
    a = a * a % p;
    b >>= 1;
  }
  return res;
}
const int maxn = 1e5 + 10;
int n, m;
vector<int> g[maxn * 2];
int root[maxn], siz[maxn];
int Find(int x) {
  if (x != root[x]) root[x] = Find(root[x]);
  return root[x];
}
vector<int> b;
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) root[i] = i, siz[i] = 1;
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    if (u < v) swap(u, v);
    g[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    map<int, int> mp;
    for (int t : g[i]) {
      mp[Find(t)]++;
    }
    for (int t : b) {
      int x = Find(t), y = Find(i);
      if (x != y) {
        if (mp[x] < siz[x]) {
          root[y] = x, siz[x] += siz[y];
        }
      }
    }
    if (i == Find(i)) b.push_back(i);
  }
  int res = 0;
  for (int i = 1; i <= n; i++)
    if (i == Find(i)) res++;
  printf("%d\n", res - 1);
  return 0;
}
