#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
const int M = 1e9 + 7;
const int64_t INF = 2e18 + 7;
const int rx[8] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int ry[8] = {0, -1, 0, 1, 1, -1, 1, -1};
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<unordered_set<int>> a(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    a[x - 1].insert(y - 1);
    a[y - 1].insert(x - 1);
  }
  set<int> have;
  for (int i = 0; i < n; ++i) {
    have.insert(i);
  }
  int res = -1;
  for (int i = 0; i < n; ++i) {
    if (!have.count(i)) continue;
    have.erase(i);
    ++res;
    queue<int> q;
    q.push(i);
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      auto to = have.begin();
      vector<int> used;
      for (; to != have.end(); ++to) {
        if (!a[v].count(*to)) {
          used.push_back(*to);
          q.push(*to);
        }
      }
      for (auto to : used) {
        have.erase(to);
      }
    }
  }
  cout << res;
  return 0;
}
