#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
vector<int> v[maxn];
int vos[maxn];
int ans;
void dfs(int now, int pre) {
  if (vos[now]) {
    ans = 0;
    return;
  }
  vos[now] = 1;
  for (int i = 0; i < v[now].size(); i++) {
    if (v[now][i] != pre) {
      dfs(v[now][i], now);
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int a, b;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  memset(vos, 0, sizeof(vos));
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    if (vos[i]) continue;
    ans = 1;
    dfs(i, 0);
    sum += ans;
  }
  printf("%d\n", sum);
  return 0;
}
