#include <bits/stdc++.h>
using namespace std;
const int N = 300009;
vector<long long> visited[N];
map<pair<int, int>, int> mp;
set<int> s;
int n, m;
void dfs(int j) {
  set<int> q;
  for (auto i : s) {
    if (mp[{j, i}] != 1) {
      q.insert(i);
    }
  }
  for (auto p : q) {
    s.erase(p);
  }
  for (auto p : q) {
    dfs(p);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    mp[{x, y}] = 1;
    mp[{y, x}] = 1;
  }
  for (int i = 1; i <= n; i++) {
    s.insert(i);
  }
  int cnt = 0;
  while (!s.empty()) {
    dfs(*s.begin());
    cnt++;
  }
  cout << cnt - 1 << endl;
}
