#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long int N = 2e5 + 100;
vector<long long int> g[N];
set<pair<long long int, long long int> > s;
vector<long long int> q[N];
long long int val[N];
bool mark[N];
int32_t main() {
  ios::sync_with_stdio(0), cout.tie(0), cin.tie(0);
  long long int n, m;
  cin >> n >> m;
  for (long long int i = 0; i < m; i++) {
    long long int u, v;
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (long long int i = 0; i < n; i++) {
    s.insert({val[i], i});
  }
  long long int cnt = 0;
  long long int k = 0;
  while (s.size()) {
    long long int v = s.begin()->second;
    q[k].push_back(v);
    mark[v] = true;
    s.erase(s.begin());
    for (long long int i = 0; i < q[k].size(); i++) {
      v = q[k][i];
      cnt++;
      for (long long int j = 0; j < g[v].size(); j++) {
        long long int u = g[v][j];
        if (!mark[u]) {
          s.erase({val[u], u});
          val[u] = cnt;
          s.insert({val[u], u});
        }
      }
      while (s.size() and s.begin()->first < cnt) {
        q[k].push_back(s.begin()->second);
        mark[s.begin()->second] = true;
        s.erase(s.begin());
      }
    }
    k++;
  }
  cout << k - 1 << endl;
  return 0;
}
