#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v[100009];
int visited[100009];
int parent[100009];
int DFS(int start) {
  visited[start] = 1;
  int i, s = v[start].size(), ans = 0;
  for (i = 0; i < s; i++) {
    if (visited[v[start][i]] == 0) {
      parent[v[start][i]] = start;
      ans = DFS(v[start][i]);
    } else if (parent[start] != v[start][i]) {
      ans = 1;
    }
    if (ans == 1) break;
  }
  return ans;
}
int main() {
  int i, j, a, b;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  int ans = 0, an;
  for (i = 1; i <= n; i++) {
    if (visited[i] == 0) {
      parent[i] = -1;
      an = DFS(i);
      if (an != 1) ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
