#include <bits/stdc++.h>
using namespace std;
set<int> adj[100001], s, parent;
void bfs(int v) {
  queue<int> q;
  q.push(v);
  s.erase(v);
  parent.insert(v);
  while (q.size()) {
    int u = q.front();
    q.pop();
    set<int> temp;
    for (int i : s) {
      if (adj[u].find(i) == adj[u].end()) {
        temp.insert(i);
        q.push(i);
      }
    }
    for (int i : temp) s.erase(i);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (__typeof(n + 1) i = (1) - (1 > n + 1); i != (n + 1) - (1 > n + 1);
       i += 1 - 2 * (1 > n + 1)) {
    s.insert(i);
  }
  for (__typeof(m) i = (0) - (0 > m); i != (m) - (0 > m);
       i += 1 - 2 * (0 > m)) {
    int a, b;
    cin >> a >> b;
    adj[a].insert(b);
    adj[b].insert(a);
  }
  for (__typeof(n + 1) i = (1) - (1 > n + 1); i != (n + 1) - (1 > n + 1);
       i += 1 - 2 * (1 > n + 1))
    if (s.find(i) != s.end()) bfs(i);
  cout << parent.size() - 1 << '\n';
  return 0;
}
