#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int> > ed(n + 1);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    ed[a].push_back(b), ed[b].push_back(a);
  }
  set<int> left;
  vector<int> vis(n + 1, -1);
  for (int i = 0; i < n; i++)
    left.insert(i + 1), sort(ed[i + 1].begin(), ed[i + 1].end());
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (vis[i + 1] != -1) continue;
    queue<int> cur;
    cur.push(i + 1), vis[i + 1] = cnt, left.erase(i + 1);
    while (!cur.empty()) {
      int u = cur.front();
      cur.pop();
      vector<int> temp;
      for (int el : left)
        if (!binary_search(ed[u].begin(), ed[u].end(), el))
          temp.push_back(el), cur.push(el);
      for (int el : temp) left.erase(el), vis[el] = cnt;
    }
    cnt++;
  }
  cout << cnt - 1 << endl;
}
