#include <bits/stdc++.h>
using namespace std;
const int N = 100003;
bool vis[N] = {0};
set<int> s, v[N];
void dfs(int x) {
  vis[x] = true;
  s.erase(x);
  for (set<int>::iterator it = s.begin(); it != s.end();) {
    int val = *it;
    it++;
    if (v[x].find(val) == v[x].end()) {
      dfs(val);
      it = s.begin();
    }
  }
}
int main() {
  int n, m, x, y, ans = 0;
  cin >> n >> m;
  for (int i = int(1); i <= int(n); i++) s.insert(i);
  for (int i = int(1); i <= int(m); i++) {
    cin >> x >> y;
    v[x].insert(y);
    v[y].insert(x);
  }
  for (int i = int(1); i <= int(n); i++) {
    if (!vis[i]) {
      ans++;
      dfs(i);
    }
  }
  cout << ans - 1 << endl;
}
