#include <bits/stdc++.h>
using namespace std;
const long long int N = 500009;
const long long int mod = 1000000007;
long long int n, m, x, y;
long long int par[N];
long long int ranki[N];
set<long long int> v[N];
set<long long int> notVis;
void init() {
  for (long long int i = 0; i < N; i++) {
    par[i] = i;
  }
}
long long int find(long long int x) {
  if (par[x] != x) {
    par[x] = find(par[x]);
    return par[x];
  }
  return x;
}
bool merge(long long int x, long long int y) {
  long long int a = find(x);
  long long int b = find(y);
  if (a == b) {
    return 1;
  }
  if (ranki[a] == ranki[b]) {
    ranki[a]++;
  } else if (ranki[a] < ranki[b]) {
    swap(a, b);
  }
  par[b] = a;
  return 0;
}
void dfs(long long int ver) {
  notVis.erase(notVis.find(ver));
  long long int prev = -1;
  while (!notVis.empty()) {
    auto it = notVis.upper_bound(prev);
    if (it == notVis.end()) break;
    long long int now = *it;
    prev = now;
    if (v[ver].find(now) != v[ver].end()) continue;
    dfs(now);
  }
}
void pre() {}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  pre();
  init();
  cin >> n >> m;
  for (long long int i = 0; i < m; i++) {
    cin >> x >> y;
    v[x].insert(y);
    v[y].insert(x);
  }
  for (long long int i = 1; i <= n; i++) {
    notVis.insert(i);
  }
  long long int ans = -1;
  for (long long int i = 1; i <= n; i++) {
    if (notVis.find(i) != notVis.end()) {
      dfs(i);
      ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}
