#include <bits/stdc++.h>
using namespace std;
const double pi =
    3.14159265358979323846264338327950288419716939937510582097494459;
int dX[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dY[] = {1, 0, -1, 0, 1, -1, 1, -1};
string alpha = "abcdefghijklmnopqrstuvwxyz";
const int N = 100100;
const int MOD = 1e9 + 7;
int seg[4 * N], idx, n, m, v, par[N];
vector<int> adj[N];
int Find(int u) {
  if (par[u] == u) return u;
  return par[u] = Find(par[u]);
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d", &u);
    scanf("%d", &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  set<int> st;
  for (int i = 1; i <= n; ++i) par[i] = i, st.insert(i);
  for (int i = 1; i <= n; ++i) {
    for (auto x : adj[i]) st.erase(x);
    for (auto x : st)
      if (x != i) par[Find(x)] = Find(i);
    st.clear();
    st.insert(i);
    for (auto x : adj[i]) st.insert(x);
  }
  set<int> out;
  for (int i = 1; i <= n; ++i) out.insert(Find(i));
  cout << (out.size()) - 1 << endl;
  return 0;
}
