#include <bits/stdc++.h>
using namespace std;
vector<int> A[100005];
int vis[100005];
int dfs(int u, int par) {
  vis[u] = 1;
  int k = 0;
  for (int i = 0; i < A[u].size(); i++) {
    if (!vis[A[u][i]])
      k = k || dfs(A[u][i], u);
    else if (vis[A[u][i]] && A[u][i] != par)
      k = 1;
  }
  return k;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, a, b;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    A[a].push_back(b);
    A[b].push_back(a);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      ans += (!dfs(i, i));
    }
  }
  cout << ans << endl;
  return 0;
}
