#include <bits/stdc++.h>
using namespace std;
vector<long long int> vec[100005];
long long int n, m;
long long int vis[100005];
long long int flg = 0;
void solve(long long int id, long long int par) {
  vis[id] = 1;
  for (long long int i = 0; i < vec[id].size(); ++i) {
    long long int v = vec[id][i];
    if (vis[v] == -1) {
      solve(v, id);
    } else {
      if (v != par) {
        flg = 0;
      }
    }
  }
}
int main() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long int i = 0; i < m; i++) {
    long long int a, b;
    cin >> a >> b;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  memset(vis, -1, sizeof(vis));
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    if (vis[i + 1] == -1) {
      flg = 1;
      solve(i + 1, -1);
      ans += flg;
    }
  }
  cout << ans << '\n';
}
