#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v[100010];
int vis[100010];
int res;
int flag = 0;
void dfs(int pre, int index) {
  vis[index] = 1;
  res++;
  for (int i = 0; i < v[index].size(); i++) {
    if (v[index][i] != pre && vis[v[index][i]]) {
      flag = 1;
      continue;
    }
    if (!vis[v[index][i]]) {
      dfs(index, v[index][i]);
    }
  }
  return;
}
int main() {
  cin >> n >> m;
  int a, b;
  res = 0;
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    flag = 0;
    if (!vis[i]) {
      dfs(0, i);
      if (!flag) {
        res--;
      }
    }
  }
  cout << n - res << endl;
  return 0;
}
