#include <bits/stdc++.h>
using namespace std;
vector<set<int>> ng;
set<int> vis;
vector<bool> done;
void dfs(int u, int p) {
  if (done[u]) return;
  done[u] = true;
  vector<int> v;
  for (int x : vis) {
    if (ng[u].find(x) == ng[u].end()) {
      v.push_back(x);
    }
  }
  for (int x : v) vis.erase(x);
  for (int x : v) {
    dfs(x, u);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  ;
  int n, m;
  cin >> n >> m;
  ng.resize(n);
  done.resize(n, false);
  vis.clear();
  for (int i = (int)(0); i <= (int)(n - 1); i++) vis.insert(i);
  for (int i = (int)(0); i <= (int)(m - 1); i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    ng[u].insert(v);
    ng[v].insert(u);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (vis.find(i) != vis.end()) {
      ans++;
      vis.erase(i);
      dfs(i, -1);
    }
  }
  cout << ans - 1 << '\n';
  return 0;
}
