#include <bits/stdc++.h>
using namespace std;
const int maxd = 1e5 + 10;
set<int> G[maxd], a;
int vis[maxd], ans;
void dfs(int x) {
  vis[x] = 1;
  a.erase(x);
  vector<int> b;
  for (int v : a)
    if (!G[x].count(v)) b.push_back(v);
  for (int v : b) a.erase(v);
  for (int v : b)
    if (!vis[v]) dfs(v);
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    G[x].insert(y);
    G[y].insert(x);
  }
  for (int i = 1; i <= n; i++) a.insert(i);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      ans++;
      dfs(i);
    }
  printf("%d", ans - 1);
  return 0;
}
