#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 1e5 + 10;
int T;
int n, m;
int vis[N];
set<int> g[N], s;
void bfs(int x) {
  queue<int> q;
  q.push(x);
  s.erase(x);
  while (!q.empty()) {
    int y = q.front();
    q.pop();
    if (vis[y]) continue;
    vis[y] = 1;
    for (auto it = s.begin(); it != s.end();) {
      int tmp = *it;
      it++;
      if (g[y].find(tmp) == g[y].end()) {
        q.push(tmp);
        s.erase(tmp);
      }
    }
  }
}
int main() {
  std::ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) s.insert(i);
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].insert(y);
    g[y].insert(x);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      bfs(i);
      ans++;
    }
  }
  cout << ans - 1 << endl;
}
