#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<set<int>> con(n + 1);
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    con[a].insert(b);
    con[b].insert(a);
  }
  vector<bool> used(n + 1, false);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (not used[i]) {
      used[i] = true;
      bool cycled = false;
      deque<int> que = {i};
      while (not que.empty()) {
        int cur = que.front();
        que.pop_front();
        for (auto t : con[cur]) {
          if (used[t]) {
            cycled = true;
          } else {
            used[t] = true;
            que.push_back(t);
          }
          con[t].erase(cur);
        }
        con[cur].clear();
      }
      ans += (not cycled);
    }
  }
  cout << ans;
  return 0;
}
