#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int tree[N];
int ranks[N];
int sz[N];
vector<vector<int>> edges(N);
int find(int x) { return x == tree[x] ? x : tree[x] = find(tree[x]); }
void link(int x, int y) {
  if (ranks[x] > ranks[y]) {
    tree[y] = x;
    sz[x] += sz[y];
  } else {
    tree[x] = y;
    sz[y] += sz[x];
    if (ranks[x] == ranks[y]) {
      ranks[y]++;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    tree[i] = i;
    ranks[i] = 0;
    sz[i] = 1;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) {
      swap(a, b);
    }
    edges[b].push_back(a);
  }
  list<int> l;
  l.push_back(0);
  for (int i = 1; i < n; i++) {
    map<int, int> mp;
    for (int a : edges[i]) {
      mp[find(a)]++;
    }
    int curr = i;
    auto itr = l.begin();
    while (itr != l.end()) {
      if (mp[*itr] < sz[*itr]) {
        link(curr, *itr);
        curr = find(curr);
        l.erase(itr++);
      } else {
        itr++;
      }
    }
    l.push_back(curr);
  }
  cout << l.size() - 1 << "\n";
}
