#include <bits/stdc++.h>
using namespace std;
int n;
int m;
int ans;
bool used[100001];
vector<int> es[100001];
bool dfs(int v, int p) {
  bool found = 0;
  used[v] = 1;
  for (int i = 0; i < es[v].size(); i++) {
    int u = es[v][i];
    if (used[u]) {
      if (u != p) found = 1;
      continue;
    }
    found |= dfs(u, v);
  }
  return found;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    es[a].push_back(b);
    es[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      if (!dfs(i, i)) ans++;
    }
  }
  printf("%d\n", ans);
}
