#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> G[N];
int ans = 0, res;
int vis[N];
void dfs(int u, int f) {
  if (vis[u]) {
    res = 1;
    return;
  } else
    vis[u] = 1;
  for (auto i : G[u])
    if (i != f) dfs(i, u);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) res = 0, dfs(i, -1), ans++, ans -= res;
  printf("%d\n", ans);
  return 0;
}
