#include <bits/stdc++.h>
using namespace std;
using ll = long long;
set<pair<int, int>> adj;
set<int> node;
void BFS(int start) {
  queue<int> q;
  q.push(start);
  while (!q.empty()) {
    int here = q.front();
    q.pop();
    vector<int> v;
    for (int next : node) {
      if (adj.find({here, next}) == adj.end()) {
        v.push_back(next);
        q.push(next);
      }
    }
    for (int remove : v) node.erase(remove);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int f, s;
    cin >> f >> s;
    f--;
    s--;
    adj.insert({f, s});
    adj.insert({s, f});
  }
  for (int i = 0; i < n; i++) node.insert(i);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (node.find(i) != node.end()) {
      ans++;
      BFS(i);
    }
  }
  cout << ans - 1 << endl;
  return 0;
}
