#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  set<pair<int, int> > cost;
  vector<int> visited(n, 0);
  vector<int> unvisited;
  for (int i = 0; i < n; i++) {
    unvisited.push_back(i);
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    cost.insert(make_pair(a, b));
    cost.insert(make_pair(b, a));
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (visited[i] == 0) {
      count++;
      visited[i] = 1;
      queue<int> todo;
      todo.push(i);
      while (todo.size() > 0) {
        int start = todo.front();
        todo.pop();
        vector<int> newunvisited;
        for (int j : unvisited) {
          if (visited[j] == 0) {
            if (cost.find(make_pair(start, j)) == cost.end()) {
              visited[j] = 1;
              todo.push(j);
            } else {
              newunvisited.push_back(j);
            }
          }
        }
        unvisited = newunvisited;
      }
    }
  }
  cout << count - 1;
}
