#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000000 + 7;
const int maxn = 100000 + 5;
const int maxm = 100000 + 5;
int n, m, c;
set<int> graph[maxn];
set<int> unvisited;
void dfs(int k) {
  vector<int> cst;
  for (int u : unvisited) {
    if (!graph[k].count(u)) cst.push_back(u);
  }
  for (int u : cst) unvisited.erase(u);
  for (int u : cst) dfs(u);
}
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    graph[a].insert(b);
    graph[b].insert(a);
  }
  for (int i = 1; i <= n; i++) unvisited.insert(i);
  while (unvisited.size()) {
    dfs(*unvisited.begin());
    c++;
  }
  printf("%d\n", c - 1);
}
