#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
;
long long max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long normalize(long long x, long long mod) {
  x %= mod;
  if (x < 0) x += mod;
  return x;
}
long long dx[4] = {0, 0, 1, -1};
long long dy[4] = {1, -1, 0, 0};
const long long mod = 1000 * 1000 * 1000 + 7;
const long long inf = 1e18 + 5;
long long powm(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
const long long N = 2e5 + 5;
long long n, m;
set<long long> graph[N];
set<long long> unvisited;
void dfs(long long v) {
  vector<long long> nxt;
  for (auto i : unvisited) {
    if (graph[v].find(i) == graph[v].end()) nxt.push_back(i);
  }
  for (auto i : nxt) unvisited.erase(i);
  for (auto i : nxt) dfs(i);
}
void solve() {
  cin >> n >> m;
  for (long long i = (1); i < (n + 1); ++i) unvisited.insert(i);
  for (long long i = (0); i < (m); ++i) {
    long long u, v;
    cin >> u >> v;
    graph[u].insert(v);
    graph[v].insert(u);
  }
  long long ans = 0;
  for (long long i = (1); i < (n + 1); ++i) {
    if (unvisited.find(i) != unvisited.end()) {
      ++ans;
      dfs(i);
    }
  }
  cout << ans - 1;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
