#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 555;
vector<int> G[maxn];
int saveori[maxn];
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int s, d;
    scanf("%d %d", &s, &d);
    G[s].push_back(d);
    G[d].push_back(s);
  }
  int flag = 0;
  int nowid = 1;
  set<int> notvis;
  for (int i = 1; i <= n; i++) {
    notvis.insert(i);
  }
  set<int> cannot;
  queue<int> q;
  q.push(1);
  int ans = 0;
  while (!notvis.empty()) {
    if (q.empty()) {
      ans++;
      q.push(*notvis.begin());
      notvis.erase(notvis.begin());
    }
    int nowid = q.front();
    q.pop();
    cannot.clear();
    for (int d : G[nowid]) {
      cannot.insert(d);
    }
    queue<int> qq;
    for (int pos : notvis) {
      if (cannot.find(pos) == cannot.end()) {
        qq.push(pos);
        q.push(pos);
      }
    }
    while (!qq.empty()) {
      notvis.erase(qq.front());
      qq.pop();
    }
  }
  cout << ans << endl;
}
signed main() { solve(); }
