#include <bits/stdc++.h>
using namespace std;
set<int> g[100001], vert;
void bfs(int s) {
  queue<int> q;
  q.push(s);
  while (q.size()) {
    int j = q.front();
    q.pop();
    vector<int> vec;
    for (auto v : vert) {
      if (g[j].find(v) == g[j].end()) {
        q.push(v);
        vec.push_back(v);
      }
    }
    for (auto h : vec) {
      vert.erase(h);
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].insert(v);
    g[v].insert(u);
  }
  for (int i = 1; i <= n; i++) {
    vert.insert(i);
  }
  int ans = 0;
  while (vert.size()) {
    auto it = vert.begin();
    int v = *it;
    vert.erase(it);
    bfs(v);
    ans++;
  }
  cout << ans - 1 << endl;
}
