#include <bits/stdc++.h>
using namespace std;
const int N = 101010;
int n, m, ans, vis[N], chuky;
vector<int> g[N];
void dfs(int u, int p) {
  vis[u] = 1;
  for (auto v : g[u]) {
    if (v == p) continue;
    if (vis[v] == 1)
      chuky = 1;
    else
      dfs(v, u);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = (1); i <= (m); ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  ans = 0;
  for (int i = (1); i <= (n); ++i)
    if (vis[i] == 0) {
      chuky = 0;
      dfs(i, i);
      ans += (chuky == 0);
    }
  cout << ans;
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
  return 0;
}
