#include <bits/stdc++.h>
using namespace std;
int used[100001];
vector<int> g[100001];
bool dfs(int v, int u = 0) {
  used[v] = 1;
  for (auto to : g[v]) {
    if (to == u || used[to] == 2) continue;
    if (!used[to]) {
      if (dfs(to, v)) return true;
      continue;
    }
    return true;
  }
  return false;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int v, u;
    cin >> v >> u;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      if (!dfs(i)) {
        res++;
      }
    }
  }
  cout << res;
  return 0;
}
