#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
bool visited[maxn];
set<int> S;
vector<set<int> > graph;
void bfs(int i) {
  queue<int> Q;
  Q.push(i);
  while (!Q.empty()) {
    int s = Q.front();
    visited[s] = true;
    Q.pop();
    for (set<int>::iterator iter = S.begin(); iter != S.end();) {
      int v = *iter;
      iter++;
      if (graph[s].find(v) == graph[s].end()) {
        S.erase(v);
        Q.push(v);
      }
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) S.insert(i);
  graph.resize(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    graph[u].insert(v);
    graph[v].insert(u);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (!visited[i]) bfs(i), ans++;
  }
  cout << --ans << endl;
}
