#include <bits/stdc++.h>
using namespace std;
long long par[100010], ran[100010];
bitset<100010> cyc;
long long ufind(long long a) {
  if (par[a] != a) par[a] = ufind(par[a]);
  return par[a];
}
long long uni(long long a, long long b) {
  if (ran[a] > ran[b])
    par[b] = a;
  else
    par[a] = b;
  if (ran[a] == ran[b]) ran[b]++;
  if (cyc[a] || cyc[b]) {
    cyc[a] = true;
    cyc[b] = true;
  }
}
int main() {
  long long t, n, m, x, y, i;
  cin >> n >> m;
  for (i = 1; i <= n; i++) par[i] = i;
  while (m--) {
    cin >> x >> y;
    long long px = ufind(x);
    long long py = ufind(y);
    if (px != py)
      uni(px, py);
    else
      cyc[px] = true;
  }
  long long cnt = 0;
  for (i = 1; i <= n; i++)
    if (par[i] == i && !cyc[i]) cnt++;
  cout << cnt;
  return 0;
}
