#include <bits/stdc++.h>
using namespace std;
int main() {
  int total, i, j, k, m, n, cost = 0, x, y;
  cin >> n >> m;
  queue<int> Q;
  set<int> left;
  vector<int> temp;
  set<int>::iterator itr;
  set<int> adj[100001];
  while (m--) {
    cin >> x >> y;
    adj[x - 1].insert(y - 1);
    adj[y - 1].insert(x - 1);
  }
  for (i = 0; i < n - 1; i++) {
    left.insert(i + 1);
  }
  Q.push(0);
  total = n - 1;
  while (total > 0) {
    if (!Q.empty()) {
      x = Q.front();
      Q.pop();
    } else {
      cost++;
      total--;
      x = *(left.begin());
      left.erase(left.begin());
    }
    temp.clear();
    for (auto it : left) {
      if (adj[x].find(it) == adj[x].end()) {
        Q.push(it);
        total--;
        temp.push_back(it);
      }
    }
    for (auto it : temp) {
      left.erase(left.find(it));
    }
  }
  printf("%d", cost);
  return 0;
}
