#include <bits/stdc++.h>
using namespace std;
const int N = 100002;
int n, m, rs;
bool Tham[N];
vector<int> a[N];
set<int> remain;
void dfs(int u) {
  Tham[u] = true;
  remain.erase(u);
  if (a[u].size())
    for (int i = 0; i <= a[u].size() - 1; ++i) {
      while (1) {
        auto it = remain.upper_bound(a[u][i]);
        if (it == remain.end() || *it >= a[u][i + 1]) break;
        dfs(*it);
      }
    }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    a[i].push_back(0);
    a[i].push_back(n + 1);
  }
  for (int i = 1; i <= n; ++i) sort(a[i].begin(), a[i].end());
  for (int i = 1; i <= n; ++i) remain.insert(i);
  for (int i = 1; i <= n; ++i)
    if (!Tham[i]) {
      dfs(i);
      rs++;
    }
  cout << rs - 1;
}
