#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
set<int> g[N], s;
set<int>::iterator it;
queue<int> q;
bool vis[N];
void bfs(int x) {
  while (!q.empty()) q.pop();
  q.push(x);
  vis[x] = 1;
  s.erase(x);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (it = s.begin(); it != s.end();) {
      int v = *it++;
      if (g[v].find(u) == g[v].end()) {
        q.push(v);
        vis[v] = 1;
        s.erase(v);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, m, x, y;
  cin >> n >> m;
  int cnt = 0;
  for (int i = 1; i <= n; i++) s.insert(i);
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    g[x].insert(y);
    g[y].insert(x);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      bfs(i);
      cnt++;
    }
  }
  cout << cnt - 1 << endl;
  return 0;
}
