#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int pre[maxn];
int mark[maxn];
int ans;
int find(int x) {
  int r = x;
  while (pre[r] != r) {
    r = pre[r];
  }
  int i = x, j;
  while (i != r) {
    j = pre[i];
    pre[i] = r;
    i = j;
  }
  return r;
}
void join(int x, int y) {
  int fx = find(x);
  int fy = find(y);
  if (fx != fy) {
    pre[fy] = fx;
    if (mark[fy]) mark[fx] = 1;
  } else {
    mark[fy] = 1;
  }
}
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(mark, 0, sizeof(mark));
    ans = 0;
    for (int i = 0; i < n; i++) pre[i] = i;
    while (m--) {
      int x, y;
      scanf("%d%d", &x, &y);
      join(x, y);
    }
    for (int i = 0; i < n; i++) {
      if (pre[i] == i && !mark[i]) ans++;
    }
    printf("%d\n", ans);
  }
  return 0;
}
