#include <bits/stdc++.h>
using namespace std;
map<int, int> edge[100001];
set<int> S;
int vis[100001];
void FindCC(int v) {
  vector<int> block;
  block.clear();
  block.push_back(v);
  vis[v] = 1;
  S.erase(v);
  for (int i = 0; i < block.size(); i++) {
    int u = block[i];
    vector<int> eliminate;
    eliminate.clear();
    for (auto node : S) {
      if (edge[u][node] == 0 && vis[node] == 0) {
        vis[node] = 1;
        block.push_back(node);
        eliminate.push_back(node);
      }
    }
    for (auto node : eliminate) {
      S.erase(node);
    }
  }
}
int main() {
  int n, m, u, v;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    edge[u][v] = edge[v][u] = 1;
  }
  int CC = 0;
  for (int i = 1; i <= n; i++) {
    S.insert(i);
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      vis[i] = 1;
      FindCC(i);
      CC++;
    }
  }
  cout << --CC;
}
