#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 2;
int n, m, tp;
vector<int> V[N];
int cnt[N], has[N * 10];
bool vis[N], used[N];
void clr() {
  for (int i = 0; i < tp; i++) cnt[has[i]] = 0, vis[has[i]] = false;
  tp = 0;
}
bool add(int i) {
  bool flag = false;
  for (int j = 0; j < V[i].size(); j++) {
    int u = V[i][j];
    if (!vis[u]) {
      vis[u] = true;
      has[tp++] = u;
      flag = true;
    }
    cnt[u]++;
  }
  if (flag) return true;
  return V[i].size() != tp;
}
int main() {
  int a, b;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a, &b);
    V[a].push_back(b);
    V[b].push_back(a);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (used[i]) continue;
    clr();
    int ct = 1;
    add(i);
    used[i] = true;
    bool flag = true;
    do {
      flag = false;
      for (int j = 1; j <= n; j++) {
        if (used[j]) continue;
        if (cnt[j] != ct) {
          used[j] = true;
          ct++;
          ans++;
          add(j);
          flag = true;
        }
      }
    } while (flag);
  }
  printf("%d\n", n - 1 - ans);
  return 0;
}
