#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int N = 100002;
int used[N];
set<pair<int, int>> e;
set<int> cu;
void dfs(int v) {
  used[v] = 1;
  vector<int> li;
  for (int u : cu)
    if (!e.count({v, u})) li.push_back(u);
  for (int i : li) cu.erase(i);
  for (int i : li)
    if (!used[i]) dfs(i);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, u, v;
  cin >> n >> m;
  for (int i = 0; i < (m); i++) {
    cin >> u >> v;
    u--;
    v--;
    e.insert({u, v});
    e.insert({v, u});
  }
  int ans = 0;
  for (int i = 0; i < (n); i++) cu.insert(i);
  for (int i = 0; i < (n); i++)
    if (cu.count(i)) {
      cu.erase(i);
      ans++;
      dfs(i);
    }
  cout << ans - 1;
}
