#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k, t, a, b, v, ans;
bool vis[100005];
int num[100005];
pair<int, int> h;
vector<vector<int> > adj;
int main() {
  set<pair<int, int> > s;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  adj.resize(n + 1);
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (i = 1; i <= n; i++) s.insert({0, i});
  int x = 0;
  while (!s.empty()) {
    v = s.begin()->second;
    if (s.begin()->first == x) ans++;
    x++;
    vis[v] = 1;
    s.erase(s.begin());
    for (int to : adj[v]) {
      if (!vis[to]) {
        s.erase({num[to], to});
        num[to]++;
        s.insert({num[to], to});
      }
    }
  }
  cout << ans - 1;
}
