#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int vis[N];
vector<int> adj[N];
int n, m;
bool cycle = false;
void dfs(int x, int par) {
  vis[x] = 1;
  for (auto w : adj[x]) {
    if (!vis[w])
      dfs(w, x);
    else if (vis[w] && w != par)
      cycle = true;
  }
}
void solve() {
  cin >> n >> m;
  int u, v;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int ans = 0;
  for (int i = 1; i < n + 1; i++) {
    if (!vis[i]) {
      ans++;
      dfs(i, 0);
      if (cycle) ans--;
    }
    cycle = false;
  }
  cout << ans;
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
