#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int inf = 2e9;
mt19937 gen(time(0));
template <class T>
int upmax(T& a, T b) {
  return (b > a) ? a = b, 1 : 0;
}
template <class T>
int upmin(T& a, T b) {
  return (b < a) ? a = b, 1 : 0;
}
template <class T>
void output(vector<T>& a, ostream& out = cerr, string r = " ") {
  for (int i = 0; i < ((int)a.size()); ++i) {
    cout << a[i] << r;
  }
  out << "\n";
}
const int N = 2e5;
vector<int> g[N], k;
int mark[N], link[N];
int mx[N], p[N];
int get(int a) {
  if (p[a] == a) return a;
  return p[a] = get(p[a]);
}
void merge(int a, int b) {
  a = get(a);
  b = get(b);
  if (a == b) return;
  if (a > b) {
    p[b] = a;
  } else {
    p[a] = b;
  }
}
void read() {}
void solutik() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    p[i] = i;
  }
  vector<pair<int, int>> rbs;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    rbs.push_back({u, v});
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    link[i] = i + 1;
  }
  for (int i = 1; i <= n; ++i) {
    g[i].push_back(0);
    g[i].push_back(n + 1);
    sort(g[i].begin(), g[i].end());
    for (int j = 0; j + 1 < g[i].size(); ++j) {
      int l = g[i][j] + 1;
      int r = g[i][j + 1] - 1;
      while (l <= r) {
        merge(i, l);
        int v = get(l);
        if (v >= r) break;
        merge(l, v + 1);
        l = v + 1;
      }
    }
  }
  int res = 0;
  for (auto i : rbs) {
    if (get(i.first) != get(i.second)) {
      merge(i.first, i.second);
      res++;
    }
  }
  cout << res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int igbfbdbfbdfbdbfdfhdjrherjehr = 1;
  while (igbfbdbfbdfbdbfdfhdjrherjehr--) {
    read();
    solutik();
    cerr << "\n\n";
  }
  return 0;
}
