#include <bits/stdc++.h>
using namespace std;
vector<int> g[100000 + 10];
int vis[100000 + 10], n, m, ans;
void dfs(int pos, int p) {
  if (vis[pos]) {
    ans = 0;
    return;
  }
  vis[pos] = 1;
  for (int i = 0; i < g[pos].size(); i++) {
    if (g[pos][i] != p) dfs(g[pos][i], pos);
  }
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n; i++) g[i].clear();
    int x, y;
    for (int i = 0; i < m; i++) {
      scanf("%d%d", &x, &y);
      g[x].push_back(y);
      g[y].push_back(x);
    }
    int sum = 0;
    for (int i = 1; i <= n; i++) {
      if (vis[i]) continue;
      ans = 1;
      dfs(i, 0);
      sum += ans;
    }
    printf("%d\n", sum);
  }
  return 0;
}
