#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100001];
int visited[100001] = {0}, parent[100001] = {0};
int dfs(int s, int p) {
  visited[s] = 1;
  int f = 1;
  for (int j = 0; j < graph[s].size(); j++)
    if (!visited[graph[s][j]]) {
      parent[graph[s][j]] = s;
      f = min(f, dfs(graph[s][j], p));
    } else if (parent[s] != graph[s][j]) {
      f = 0;
    }
  return f;
}
int main() {
  int n, m, ans = 0, i, x, y;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  for (i = 1; i <= n; i++)
    if (!visited[i]) {
      parent[i] = -1;
      ans += dfs(i, i);
    }
  cout << ans << endl;
  return 0;
}
