#include <bits/stdc++.h>
using namespace std;
const int maxm = 1e5 + 5;
int pre[maxm];
bool mark[maxm];
int n, m;
int ffind(int x) { return pre[x] == x ? x : pre[x] = ffind(pre[x]); }
signed main() {
  for (int i = 0; i < maxm; i++) {
    pre[i] = i;
  }
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    int x = ffind(a);
    int y = ffind(b);
    if (x != y) {
      pre[x] = y;
      mark[y] |= mark[x];
    } else {
      mark[x] = 1;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (pre[i] == i) {
      if (!mark[i]) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
