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