#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
int n, m, vis[N];
vector<int> v[N];
void add(int node, set<pair<int, int> > &s, set<pair<int, int> > &d) {
  auto v = *s.lower_bound(make_pair(node, -1));
  s.erase(v);
  v.second++;
  s.insert(v);
  v.second--;
  swap(v.first, v.second);
  d.erase(v);
  v.first++;
  d.insert(v);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    vis[i] = 1;
    set<pair<int, int> > s, d;
    for (int j = 1; j <= n; j++) {
      if (!vis[j]) {
        s.insert(make_pair(j, 0));
        d.insert(make_pair(0, j));
      }
    }
    int cnt = 1;
    for (auto &j : v[i]) {
      if (!vis[j]) add(j, s, d);
    }
    while (d.size() && (*d.begin()).first != cnt) {
      auto top = *d.begin();
      d.erase(top);
      swap(top.first, top.second);
      s.erase(top);
      int node = top.first;
      vis[node] = 1;
      cnt++;
      for (auto &j : v[node]) {
        if (!vis[j]) add(j, s, d);
      }
    }
    ans++;
  }
  cout << ans - 1 << endl;
}
