#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000;
long long gcd(long long a, long long b) {
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}
long long lim = 150005;
vector<long long> adj[150005];
vector<long long> vis(lim, 0);
long long f = 0;
void dfs(long long x, long long parent) {
  if (vis[x] == 1) return;
  vis[x] = 1;
  for (auto &it : adj[x]) {
    if (vis[it] != 1) {
      dfs(it, x);
    } else if (it != parent) {
      f = 1;
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) {
      f = 0;
      dfs(i, -1);
      if (f == 0) {
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
