#include <bits/stdc++.h>
using namespace std;
int n, m, ans, fa[100001];
bool mark[100001];
int find(int x) {
  if (x == fa[x]) return x;
  return fa[x] = find(fa[x]);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    int fx = find(x), fy = find(y);
    if (fx != fy) {
      fa[fx] = fy;
      if (mark[fx] || mark[x] || mark[fy] || mark[y])
        mark[fx] = mark[x] = mark[fy] = mark[y] = 1;
    } else
      mark[fx] = mark[x] = mark[fy] = mark[y] = 1;
  }
  for (int i = 1; i <= n; i++)
    if (find(i) == i && !mark[i]) ans++;
  cout << ans << endl;
  return 0;
}
