#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
vector<int> g[maxn];
int s[maxn], r[maxn], cant[maxn];
void join(int a, int b) {
  if (a == b) return;
  if (r[a] < r[b]) swap(a, b);
  r[a] += r[b];
  s[b] = s[a];
}
int root(int i) {
  if (i != s[i]) s[i] = root(s[i]);
  return s[i];
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  int a, b;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) sort(g[i].begin(), g[i].end());
  set<int> ss;
  for (int i = 1; i <= n; i++) {
    s[i] = i, r[i] = 1;
    for (auto j : g[i]) {
      if (j > i) break;
      int r = root(j);
      cant[r]++;
    }
    for (auto j : ss)
      if (cant[root(j)] < r[root(j)]) {
        if (ss.count(root(i))) ss.erase(ss.find(root(i)));
        join(root(j), root(i));
      }
    for (auto j : g[i]) {
      if (j > i) break;
      cant[root(j)] = 0;
    }
    ss.insert(root(i));
  }
  set<int> S;
  for (int i = 1; i <= n; i++) S.insert(root(i));
  cout << S.size() - 1 << "\n";
  return 0;
}
