#include <bits/stdc++.h>
using namespace std;
long long n, i, j, k, l, sum = 0, flag = 0, t, first, m, ans = 0, second,
                         visited[100005];
vector<long long int> v[100005];
void dfs(int node) {
  first++;
  visited[node] = 1;
  second += v[node].size();
  for (auto j : v[node]) {
    if (!visited[j]) dfs(j);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> j >> k;
    v[k].push_back(j);
    v[j].push_back(k);
  }
  for (i = 1; i <= n; i++) {
    if (!visited[i]) {
      dfs(i);
      second /= 2;
      if (first == second + 1) ans++;
      first = 0;
      second = 0;
    }
  }
  cout << ans << '\n';
  return 0;
}
