#include <bits/stdc++.h>
using namespace std;
std::vector<int> adj[200000];
bool visited[200000];
int dfs(int v, int parent) {
  visited[v] = 1;
  int cycle = 0;
  for (auto it : adj[v]) {
    if (visited[it] == true && it != parent) {
      cycle = 1;
    }
    if (!visited[it]) {
      if (dfs(it, v)) {
        cycle = 1;
      }
    }
  }
  return cycle;
}
void dfs_helper(int n) {
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (visited[i] == false) {
      if (!dfs(i, -1)) {
        ans += 1;
      }
    }
  }
  cout << ans;
}
int main() {
  int n, m, u, v;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs_helper(n);
}
