#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int ans = 0;
set<int> st;
map<pair<int, int>, bool> mp;
void dfs(int x) {
  vector<int> v;
  for (auto it = st.begin(); it != st.end(); ++it) {
    if (mp.find(make_pair(x, *it)) == mp.end()) {
      v.push_back(*it);
    }
  }
  for (int i = 0; i < v.size(); ++i) st.erase(v[i]);
  for (int i = 0; i < v.size(); ++i) {
    dfs(v[i]);
  }
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) st.insert(i);
  int mx = 0, idx = 0, deg[N] = {};
  for (int i = 0; i < m; ++i) {
    int l, r;
    scanf("%d %d", &l, &r);
    l--, r--;
    mp[make_pair(l, r)] = 1;
    mp[make_pair(r, l)] = 1;
  }
  for (int i = 0; i < n; ++i) {
    if (st.find(i) != st.end()) {
      ans++;
      st.erase(i);
      dfs(i);
    }
  }
  cout << ans - 1 << endl;
  return 0;
}
