#include <bits/stdc++.h>
using namespace std;
int dfs(int u, vector<int> adj[], vector<bool> &vist, int p) {
  int i;
  vist[u] = true;
  for (i = 0; i < adj[u].size(); i++) {
    if (vist[adj[u][i]] == true && adj[u][i] != p) return 1;
    if (vist[adj[u][i]] == false && adj[u][i] != p) {
      if (dfs(adj[u][i], adj, vist, u) == 1) return 1;
    }
  }
  return 0;
}
int main() {
  int n, m, c = 0, u, v, i;
  cin >> n >> m;
  vector<int> adj[100009];
  for (i = 0; i < m; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  vector<bool> vist(100009, false);
  for (i = 1; i <= n; i++) {
    if (vist[i] == false) {
      if (dfs(i, adj, vist, 0) == 0) c++;
    }
  }
  cout << c << endl;
  return 0;
}
