#include <bits/stdc++.h>
using namespace std;
vector<int> v[100010];
int vis[100010];
int dfs(int u, int fa) {
  if (vis[u]) return 1;
  vis[u] = 1;
  for (int i = 0; i < v[u].size(); i++) {
    int mm = v[u][i];
    if (mm == fa) continue;
    if (dfs(mm, u)) return 1;
  }
  return 0;
}
int main() {
  int n, m, x, y;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) ans += dfs(i, 0) ^ 1;
  }
  cout << ans << endl;
  return 0;
}
