#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
int n, m, a, b, ans = 0;
bool vis[N];
vector<int> g[N];
bool cycle = false;
void dfs(int u, int p) {
  if (vis[u]) {
    cycle = true;
    return;
  }
  vis[u] = true;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == p) continue;
    dfs(v, u);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      cycle = false;
      dfs(i, -1);
      ans += (!cycle);
    }
  }
  printf("%d\n", ans);
  return 0;
}
