#include <bits/stdc++.h>
using namespace std;
int const SIZE = 100000 + 10;
set<int> G[SIZE], vis;
int n, m;
int v[SIZE];
int ans;
void dfs(int x) {
  vis.erase(x);
  v[x] = 1;
  vector<int> u;
  for (int y : vis) {
    if (!G[x].count(y)) {
      u.push_back(y);
    }
  }
  for (int t : u) {
    vis.erase(t);
  }
  for (int t : u) {
    v[t] = 1;
    dfs(t);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    G[x].insert(y);
    G[y].insert(x);
  }
  for (int i = 1; i <= n; ++i) vis.insert(i);
  for (int i = 1; i <= n; ++i) {
    if (!v[i]) {
      ans++;
      dfs(i);
    }
  }
  cout << ans - 1 << endl;
  return 0;
}
