#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, m, u, v;
  cin >> n >> m;
  vector<long long> deg(n, 0);
  vector<vector<long long>> g(n);
  for (long long i = 0; i < m; i++) {
    cin >> u >> v;
    deg[u - 1]++;
    deg[v - 1]++;
    g[u - 1].push_back(v - 1);
    g[v - 1].push_back(u - 1);
  }
  long long maxdeg = n - 1;
  long long res = 0;
  set<pair<long long, long long>> pq;
  for (long long i = 0; i < n; i++) pq.insert({deg[i], i});
  vector<bool> done(n, false);
  while (maxdeg) {
    auto it = pq.end();
    it--;
    pair<long long, long long> p = *it;
    long long d = p.first;
    v = p.second;
    pq.erase(it);
    if (done[v]) continue;
    done[v] = true;
    if (d == maxdeg) res++;
    for (long long nb : g[v]) {
      pq.erase({deg[nb], nb});
      deg[nb]--;
      pq.insert({deg[nb], nb});
    }
    maxdeg--;
  }
  cout << res << "\n";
}
