#include <bits/stdc++.h>
using namespace std;
const int NMAX = 2e5 + 5;
int n, m, sz = 0;
set<int> unvisited;
set<int> g[NMAX];
vector<int> v;
void dfs(int u) {
  sz++;
  vector<int> next;
  for (auto &it : unvisited) {
    if (g[u].find(it) == g[u].end()) next.push_back(it);
  }
  for (auto &it : next) unvisited.erase(it);
  for (auto &it : next) dfs(it);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) unvisited.insert(i);
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].insert(v);
    g[v].insert(u);
  }
  for (int i = 1; i <= n; i++) {
    if (unvisited.find(i) != unvisited.end()) {
      unvisited.erase(i);
      sz = 0;
      dfs(i);
      v.push_back(sz);
    }
  }
  cout << v.size() - 1 << endl;
  return 0;
}
