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