#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1000 * 100 + 100;
int n, m, res[N], ans;
bool vis[N];
set<int> vert, adj[N];
void read() {
  cin >> n >> m;
  for (int i = 1, v, u; i <= m; i++) {
    cin >> v >> u;
    adj[v].insert(u);
    adj[u].insert(v);
  }
}
void bfs(int root) {
  queue<int> q;
  q.push(root);
  res[ans]++;
  while (q.size()) {
    vector<int> vec;
    for (auto it : vert)
      if (adj[q.front()].find(it) == adj[q.front()].end()) {
        q.push(it);
        vec.push_back(it);
        res[ans]++;
      }
    for (auto it : vec) vert.erase(it);
    q.pop();
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  read();
  for (int i = 1; i <= n; i++) vert.insert(i);
  while (vert.size()) {
    auto it = vert.begin();
    int v = *it;
    vert.erase(it);
    bfs(v);
    ans++;
  }
  cout << ans - 1 << endl;
  return 0;
}
