#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int n, m, lab[MAXN];
bool cyc[MAXN];
int getRoot(int u) {
  if (lab[u] < 0) return u;
  return lab[u] = getRoot(lab[u]);
}
void merge(int u, int v) {
  u = getRoot(u);
  v = getRoot(v);
  if (u == v) {
    cyc[u] = true;
    return;
  }
  if (lab[u] > lab[v]) swap(u, v);
  lab[u] += lab[v];
  lab[v] = u;
  cyc[u] = (cyc[u] || cyc[v]);
}
int main() {
  memset(cyc, false, sizeof(cyc));
  cin >> n >> m;
  for (int i = (1); i <= (n); i++) lab[i] = -1;
  while (m--) {
    int u, v;
    cin >> u >> v;
    merge(u, v);
  }
  int res = 0;
  for (int u = (1); u <= (n); u++)
    if (lab[u] < 0 && !cyc[u]) res++;
  cout << res;
  return 0;
}
