#include <bits/stdc++.h>
using namespace std;
int p[100010][2], root[100010];
int find_root(int u) {
  if (u == root[u]) return u;
  return root[u] = find_root(root[u]);
}
int main() {
  int N, M, i, u, v, uu, vv;
  scanf("%d %d", &N, &M);
  for (i = 1; i <= N; i++) {
    root[i] = i;
    p[i][0] = 1;
  }
  for (i = 0; i < M; i++) {
    scanf("%d %d", &u, &v);
    uu = find_root(u);
    vv = find_root(v);
    if (uu == vv)
      p[uu][1]++;
    else {
      if (p[uu][0] > p[vv][0]) swap(uu, vv);
      root[uu] = vv;
      p[vv][0] += p[uu][0];
      p[vv][1] += p[uu][1] + 1;
      p[uu][0] = p[uu][1] = 0;
    }
  }
  int ans = 0;
  for (i = 1; i <= N; i++) {
    if (p[i][0] <= p[i][1]) continue;
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}
