#include <bits/stdc++.h>
using namespace std;
set<int> s;
set<pair<int, int> > muchii;
void bfs(int start) {
  queue<int> q;
  q.push(start);
  while (!q.empty()) {
    int nod = q.front();
    q.pop();
    vector<int> el;
    for (auto i : s) {
      int u = i;
      if (!muchii.count({nod, u})) {
        el.push_back(u);
        q.push(u);
      }
    }
    for (auto i : el) s.erase(i);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    muchii.insert({x, y});
    muchii.insert({y, x});
  }
  for (int i = 1; i <= n; i++) {
    s.insert(i);
  }
  int res = 0;
  while (s.size() > 0) {
    res++;
    int nod = *s.begin();
    s.erase(nod);
    bfs(nod);
  }
  cout << res - 1;
}
