#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000")
#pragma warning(disable : 6031)
using namespace std;
const long long mod = int(1e9) + 7;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  set<pair<int, int> > ones;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    ones.emplace(min(a, b), max(a, b));
  }
  vector<int> nv(n);
  iota((nv).begin(), (nv).end(), 0);
  unordered_set<int> nvs((nv).begin(), (nv).end());
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (nvs.count(i)) {
      res++;
      queue<int> q;
      q.push(i);
      nvs.erase(i);
      while (!q.empty()) {
        int cur = q.front();
        q.pop();
        vector<int> found;
        for (int j : nvs) {
          if (!ones.count(pair<int, int>(min(cur, j), max(cur, j))))
            found.push_back(j);
        }
        for (int to_err : found) {
          nvs.erase(to_err);
          q.push(to_err);
        }
      }
    }
  }
  cout << res - 1;
  return 0;
}
