#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int pre[MAXN];
int faind(int x) {
  if (pre[x] == x) return x;
  int fd = faind(pre[x]);
  pre[x] = fd;
  return fd;
}
bool fk[MAXN];
void join(int a, int b) {
  int fa = faind(a), fb = faind(b);
  if (fa == fb) {
    fk[fa] = true;
    return;
  }
  if (fk[fa] || fk[fb]) fk[fa] = fk[fb] = true;
  if (fa < fb)
    pre[fb] = fa;
  else
    pre[fa] = fb;
}
int main() {
  int n, m, u, v, cnt = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    pre[i] = i;
    fk[i] = false;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    join(u, v);
  }
  for (int i = 1; i <= n; i++) {
    if (!fk[faind(i)]) {
      cnt++;
      fk[faind(i)] = true;
    }
  }
  printf("%d\n", cnt);
  return 0;
}
