#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 7;
int n, m, tot;
bool Book[N];
vector<int> E[N];
set<int> S, S1;
queue<int> Q;
inline void BFS(int SS) {
  Q.push(SS), S.erase(SS);
  while (!Q.empty()) {
    int u = Q.front();
    S1.clear(), Q.pop();
    for (auto v : E[u])
      if (S.find(v) != S.end()) S1.insert(v), S.erase(v);
    swap(S1, S);
    for (auto v : S1) Q.push(v);
  }
}
int main() {
  int u, v;
  scanf("%d%d", &n, &m);
  for (int i = (1), iLimit = (m); i <= iLimit; (++(i)))
    scanf("%d%d", &u, &v), E[u].push_back(v), E[v].push_back(u);
  for (int i = (1), iLimit = (n); i <= iLimit; (++(i))) S.insert(i);
  for (int i = (1), iLimit = (n); i <= iLimit; (++(i)))
    if (S.find(i) != S.end()) BFS(i), (++(tot));
  printf("%d\n", tot - 1);
  return 0;
}
