#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int p[N], s[N];
bool us[N];
int Find(int u) { return p[u] == u ? u : p[u] = Find(p[u]); }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    p[i] = i;
    s[i] = 1;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u = Find(u);
    v = Find(v);
    if (s[u] < s[v]) {
      swap(u, v);
    }
    p[v] = u;
    us[u] |= us[v];
    if (u == v) {
      us[v] = true;
    } else {
      s[u] += s[v];
    }
  }
  int res = 0;
  for (int u = 1; u <= n; u++) {
    if (u == p[u]) {
      res += !us[u];
    }
  }
  printf("%d\n", res);
}
