#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 5;
int n, m;
vector<int> head[maxN];
bool mark[maxN];
bool DFS(int u, int pre) {
  mark[u] = true;
  bool ok = false;
  for (int v : head[u]) {
    if (v == pre) continue;
    if (mark[v])
      ok = true;
    else
      ok |= DFS(v, u);
  }
  return ok;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    head[u].push_back(v);
    head[v].push_back(u);
  }
  int res = 0;
  for (int u = 1; u <= n; ++u)
    if (!mark[u]) res += !DFS(u, 0);
  cout << res;
  return 0;
}
