#include <bits/stdc++.h>
using namespace std;
set<int> second[100001];
int n, m;
set<int> unused;
void dfs(int node) {
  unused.erase(node);
  vector<int> temp;
  for (auto &c : unused) {
    if (second[node].find(c) == second[node].end()) {
      temp.push_back(c);
    }
  }
  for (auto &c : temp) unused.erase(c);
  for (auto &c : temp) dfs(c);
  temp.clear();
}
void solve() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    second[a].insert(b);
    second[b].insert(a);
  }
  for (int i = 0; i < n; i++) unused.insert(i);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (unused.find(i) != unused.end()) {
      ans++;
      dfs(i);
    }
  }
  cout << ans - 1 << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}
