#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <typename T>
istream& operator>>(istream& in, pair<T, T>& p) {
  in >> p.first >> p.second;
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, pair<T, T> p) {
  out << p.first << " " << p.second;
  return out;
}
mt19937 gen(time(0));
int n, m;
vector<set<int>> arr;
vector<bool> v;
set<int> s;
void dfs(int x) {
  v[x] = 1;
  vector<int> tmp;
  for (auto i : s) {
    if (!arr[x].count(i)) {
      tmp.push_back(i);
    }
  }
  for (auto i : tmp) {
    s.erase(i);
  }
  for (auto i : tmp) {
    dfs(i);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> n >> m;
  arr.resize(n);
  v.resize(n, 0);
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--, b--;
    arr[a].insert(b);
    arr[b].insert(a);
  }
  for (int i = 0; i < n; i++) {
    s.insert(i);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (!v[i]) {
      ans++;
      dfs(i);
    }
  }
  cout << ans - 1 << '\n';
  return 0;
}
