#include <bits/stdc++.h>
using namespace std;
int n, m;
set<int> nadj[100005];
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    nadj[u].insert(v);
    nadj[v].insert(u);
  }
  list<int> tovis;
  for (int i = 0; i < n; i++) {
    tovis.push_back(i);
  }
  int cc = 0;
  for (auto i = tovis.begin(); i != tovis.end();) {
    cc++;
    queue<int> q;
    q.push(*i);
    tovis.erase(i++);
    while (!q.empty()) {
      int curr = q.front();
      q.pop();
      for (auto it = tovis.begin(); it != tovis.end();) {
        if (nadj[curr].find(*it) == nadj[curr].end()) {
          q.push(*it);
          if (it == i) {
            ++i;
          }
          tovis.erase(it++);
        } else {
          ++it;
        }
      }
    }
  }
  cout << cc - 1 << '\n';
}
