#include <bits/stdc++.h>
using namespace std;
int const MN = 1e5 + 100;
bool vis[MN], t;
vector<int> adj[MN];
int n, m, ans;
void dfs(int v, int p = -1) {
  vis[v] = 1;
  for (auto u : adj[v]) {
    if (u == p) continue;
    if (vis[u])
      t = 1;
    else
      dfs(u, v);
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0, u, v; i < m; i++) {
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    t = 0;
    dfs(i);
    if (!t) ans++;
  }
  cout << ans;
}
