#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a << endl;
  err(++it, args...);
}
const long long mod = 1e9 + 7;
const long long maxN = 1e9;
const long long INF = 1e18;
const long double EPS = 1e-9;
const int N = 1e5 + 1;
set<int> unused, edges[N];
int n, m, ans;
void dfs(int v) {
  unused.erase(v);
  int cur = -1;
  while (true) {
    auto it = unused.upper_bound(cur);
    if (it == unused.end()) break;
    cur = *it;
    if (edges[v].find(cur) != edges[v].end())
      continue;
    else
      dfs(cur);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    edges[x].insert(y);
    edges[y].insert(x);
  }
  for (int i = 1; i <= n; i++) unused.insert(i);
  for (int i = 1; i <= n; i++) {
    if (unused.find(i) != unused.end()) {
      ans++;
      dfs(i);
    }
  }
  cout << ans - 1 << endl;
  return 0;
}
