#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vvll = vector<vll>;
set<ll> nv;
map<ll, set<ll>> e;
void dfs(ll v) {
  nv.erase(v);
  for (auto i = nv.begin(); i != nv.end();) {
    if (!e[v].count(*i) && nv.count(*i)) dfs(*i);
    i = nv.upper_bound(*i);
    if (i == nv.end()) return;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  ll n;
  cin >> n;
  ll m;
  cin >> m;
  for (ll i = 0; i < (ll)n; ++i) nv.insert(i);
  for (ll i = 0; i < (ll)m; ++i) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    e[a].insert(b);
    e[b].insert(a);
  }
  ll res = 0;
  for (ll i = 0; i < (ll)n; ++i) {
    if (nv.count(i)) {
      res++;
      dfs(i);
    }
  }
  cout << res - 1 << endl;
  return 0;
}
