#include <bits/stdc++.h>
using namespace std;
const int Mn = 100017;
vector<int> E[Mn];
set<int> s, tmp;
bool vis[Mn], book[Mn];
void BFS(int x) {
  queue<int> q;
  q.push(x);
  vis[x] = true;
  s.erase(s.find(x));
  while (!q.empty()) {
    tmp.clear();
    int now = q.front();
    q.pop();
    for (auto i : E[now]) book[i] = true;
    for (auto i : s) {
      if (book[i] || vis[i]) continue;
      q.push(i);
      vis[i] = true;
      tmp.insert(i);
    }
    for (auto i : tmp) s.erase(s.find(i));
    for (auto i : E[now]) book[i] = false;
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  if (m == 0) {
    puts("0");
    return 0;
  }
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    E[x].push_back(y);
    E[y].push_back(x);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) s.insert(i);
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) {
      ++ans;
      BFS(i);
    }
  printf("%d\n", ans - 1);
  return 0;
}
