#include <bits/stdc++.h>
using namespace std;
bool vis[100005];
vector<int> adj[100005];
int n, m, u, v, d_edges, nodes, sz, answer;
void dfs(int c) {
  vis[c] = 1;
  nodes++;
  d_edges += adj[c].size();
  for (int j = 0; j < adj[c].size(); j++) {
    if (!vis[adj[c][j]]) dfs(adj[c][j]);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i);
      if (nodes * 2 > d_edges) answer++;
      d_edges = nodes = 0;
    }
  }
  printf("%d", answer);
  return 0;
}
