#include <bits/stdc++.h>
using namespace std;
int z[110001], res, u, v, n, m;
long long pr[110001];
int root(int u) { return pr[u] < 0 ? u : root(pr[u]); }
void merge(int u, int v) {
  if ((u = root(u)) == (v = root(v))) {
    z[u] = 1;
    return;
  }
  if (pr[u] > pr[v]) swap(u, v);
  pr[u] += pr[v];
  pr[v] = u;
  z[u] = max(z[u], z[v]);
  z[v] = max(z[v], z[u]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int test = 1;
  while (test--) {
    scanf("%d%d", &n, &m);
    for (int i = 0; i <= n; ++i) pr[i] = -1;
    for (int i = 1; i <= m; ++i) {
      scanf("%d%d", &u, &v);
      merge(u, v);
    }
    int res = 0;
    for (int i = 1; i <= n; ++i)
      if (pr[i] < 0 && z[i] == 0) res++;
    printf("%d\n", res);
  }
  return 0;
}
