#include <bits/stdc++.h>
using namespace std;
int t = 1, n, m, k, ans;
vector<bool> used, parc;
vector<int> par;
int find(int a) {
  if (par[a] == a)
    return a;
  else
    return par[a] = find(par[a]);
}
void solve() {
  cin >> n >> m;
  par.resize(n + 1);
  parc.resize(n + 1, false);
  used.resize(n + 1, false);
  for (int i = 1; i <= n; i++) par[i] = i;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    int a1 = find(a);
    int b1 = find(b);
    if (a1 != b1) {
      par[a1] = b1;
      if (parc[a1]) parc[b1] = true;
    } else {
      parc[a1] = true;
    }
  }
  for (int i = 1; i <= n; i++) {
    int p = find(i);
    if (!used[p]) {
      if (!parc[p]) ans++;
      used[p] = true;
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  while (t--) {
    solve();
  }
  return 0;
}
