#include <bits/stdc++.h>
using namespace ::std;
const long long maxn = 1e5 + 500;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 500;
bool por[maxn];
long long par[maxn];
bool yal[maxn];
long long find_dad(long long a) {
  if (par[a] == a) {
    return a;
  }
  par[a] = find_dad(par[a]);
  return par[a];
}
int main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    par[i] = i;
  }
  for (long long i = 0; i < m; i++) {
    long long v, u;
    cin >> v >> u;
    v--;
    u--;
    yal[u] = 1;
    yal[v] = 1;
    u = find_dad(u);
    v = find_dad(v);
    if (v == u) {
      por[v] = 1;
    } else {
      par[u] = v;
      por[v] |= por[u];
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (par[i] == i && por[i] == 0) {
      ans++;
    }
  }
  cout << ans;
}
