#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
long long n, m;
set<long long> g[N];
vector<long long> gDash[N];
bool vis[N];
long long k;
void dfs(long long v) {
  vis[v] = true;
  for (long long x : gDash[v]) {
    if (!vis[x]) dfs(x);
  }
}
signed main() {
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].insert(v);
    g[v].insert(u);
  }
  long long mn = N;
  long long node;
  for (long long i = 1; i <= n; i++) {
    if (g[i].size() < mn) {
      mn = g[i].size();
      node = i;
    }
  }
  set<long long> complement;
  for (long long i = 1; i <= n; i++) {
    if (i != node && g[node].find(i) == g[node].end()) {
      complement.insert(i);
      gDash[node].push_back(i);
      gDash[i].push_back(node);
    }
  }
  for (long long x : g[node]) {
    for (long long i = 1; i <= n; i++) {
      if (i != x && g[x].find(i) == g[x].end()) {
        gDash[x].push_back(i);
        gDash[i].push_back(x);
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) {
      k++;
      dfs(i);
    }
  }
  cout << k - 1 << endl;
}
