#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
set<int> e[MAXN], st;
bool vis[MAXN], on_edge[MAXN];
int main() {
  ios::sync_with_stdio(false);
  int n, m, x, y;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    e[x].insert(y);
    e[y].insert(x);
  }
  for (int i = 1; i <= n; i++) st.insert(i);
  int ans = 0;
  queue<int> q;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    ans++;
    vis[i] = true;
    q.push(i);
    while (!q.empty()) {
      int now = q.front();
      q.pop();
      for (auto j = st.begin(); j != st.end();) {
        int v = *j++;
        if (vis[v]) continue;
        if (!e[now].count(v)) {
          vis[v] = true;
          q.push(v);
          st.erase(v);
        }
      }
    }
  }
  cout << ans - 1 << endl;
}
