#include <bits/stdc++.h>
using namespace std;
int n, m;
int ans = 0;
int ans1;
bool vis[100005];
vector<int> vec[100005];
void dfs(int pos, int pre) {
  if (vis[pos]) {
    ans1 = 0;
    return;
  }
  vis[pos] = 1;
  for (int i = 0; i < vec[pos].size(); i++) {
    if (vec[pos][i] != pre) dfs(vec[pos][i], pos);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i])
      continue;
    else {
      ans1 = 1;
      dfs(i, 0);
      ans = ans + ans1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
