#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int n, m;
set<int> g[100005], vis;
int v[100005];
set<int>::iterator it;
void dfs(int x) {
  v[x] = 1;
  vis.erase(x);
  vector<int> ret;
  for (it = vis.begin(); it != vis.end(); it++)
    if (!g[x].count(*it)) ret.push_back(*it);
  for (int i = (0); i < (ret.size()); i++) vis.erase(ret[i]);
  for (int i = (0); i < (ret.size()); i++) v[ret[i]] = 1, dfs(ret[i]);
}
int main() {
  scanf("%d%d", &n, &m);
  int x, y;
  while (m--) {
    scanf("%d%d", &x, &y);
    g[x].insert(y), g[y].insert(x);
  }
  int ans = -1;
  for (int i = (1); i <= (n); i++) vis.insert(i);
  for (int i = (1); i <= (n); i++)
    if (!v[i]) ans++, dfs(i);
  printf("%d\n", ans);
  return 0;
}
