#include <bits/stdc++.h>
using namespace std;
vector<int> a[100100];
int ans;
int vis[200000];
void dfs(int per, int now) {
  if (vis[per]) {
    ans = 0;
    return;
  }
  vis[per] = 1;
  for (int i = 0; i < a[per].size(); i++) {
    if (a[per][i] != now) dfs(a[per][i], per);
  }
}
int main() {
  int n, m, x, y, ret;
  while (cin >> n >> m) {
    ans = 1, ret = 0;
    memset(vis, 0, sizeof vis);
    for (int i = 0; i < m; i++) {
      cin >> x >> y;
      a[x].push_back(y);
      a[y].push_back(x);
    }
    for (int i = 1; i <= n; i++) {
      if (vis[i]) continue;
      ans = 1;
      dfs(i, 0);
      ret += ans;
    }
    cout << ret << endl;
  }
}
