#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 10;
const int mod = 998244353;
int n, m, fa[M], siz[M];
vector<int> G[M], v;
map<int, int> mp;
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  int cnt = 0;
  for (int i = 1; i <= n; ++i) fa[i] = i;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i = 1; i <= n; ++i) {
    mp.clear();
    siz[i] = 1;
    for (int x : G[i]) {
      if (x > i) continue;
      int t = find(x);
      ++mp[t];
    }
    for (int x : v) {
      int t = find(x);
      if (siz[t] > mp[t]) {
        int tf = find(i);
        if (tf == t) continue;
        fa[tf] = t;
        siz[t] += siz[tf];
      }
    }
    if (fa[i] == i) {
      v.push_back(i);
    }
  }
  for (int i = 1; i <= n; ++i)
    if (fa[i] == i) {
      ++cnt;
    }
  cout << cnt - 1 << '\n';
}
