#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 99;
int n, m, pre[maxn], nxt[maxn], vst[maxn], flag[maxn];
vector<int> G[maxn];
void del(int i) {
  nxt[pre[i]] = nxt[i];
  if (~nxt[i]) pre[nxt[i]] = pre[i];
}
void bfs(int id) {
  queue<int> que;
  que.push(id);
  while (!que.empty()) {
    int now = que.front();
    que.pop();
    for (int x : G[now])
      if (!vst[x]) flag[x] = 1;
    for (int i = nxt[0]; ~i; i = nxt[i]) {
      if (flag[i])
        flag[i] = 0;
      else
        vst[i] = 1, que.push(i), del(i);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  nxt[0] = 1;
  nxt[n] = -1;
  for (int i = 1; i < n; i++) pre[i + 1] = i, nxt[i] = i + 1;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (vst[i]) continue;
    ans++;
    bfs(i);
  }
  cout << ans - 1;
  return 0;
}
