#include <bits/stdc++.h>
using namespace std;
int par[100010];
vector<int> a[100010];
int pa(int x) {
  if (par[x] == x) return x;
  return par[x] = pa(par[x]);
}
int vis[100010], l[100010];
int main() {
  int n, m;
  while (cin >> n >> m) {
    long long ans = 0;
    int x, y;
    set<pair<int, int>> st;
    vector<int> v;
    for (int i = 0; i < m; ++i) {
      scanf("%d%d", &x, &y);
      a[x].push_back(y);
      a[y].push_back(x);
    }
    for (int i = 1; i <= n; ++i) {
      v.push_back(i);
    }
    for (int i = 1; i <= n; ++i) {
      par[i] = i;
    }
    for (int ii = 0; ii < 30; ++ii) {
      random_shuffle(v.begin(), v.end());
      for (int i = 1; i <= n; ++i) {
        vis[i] = 0;
      }
      for (auto it : v) {
        int tmp = it;
        if (vis[tmp]) {
          continue;
        }
        for (int i = 1; i <= n; ++i) {
          l[i] = 0;
        }
        for (int i = 0; i < a[tmp].size(); ++i) {
          l[a[tmp][i]] = 1;
        }
        for (int i = 1; i <= n; ++i) {
          if (l[i]) continue;
          par[pa(tmp)] = pa(i);
          vis[i] = 1;
        }
      }
    }
    for (int i = 1; i <= n; ++i) {
      if (par[i] == i) {
        ++ans;
      }
    }
    ans = ans - 1;
    cout << ans << endl;
  }
  return 0;
}
