#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> g[100069];
int vis[100069];
int nodes;
int edges;
int flag;
void dfs(int i, int root, int par) {
  nodes++;
  vis[i] = 1;
  for (int j = 0; j < g[i].size(); j++) {
    int u = g[i][j];
    if (vis[u] && u != par) flag = 1;
    if (!vis[u]) dfs(u, root, i);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int ans = 0;
  for (int i = 1; i < n + 1; i++) {
    flag = 0;
    if (!vis[i]) {
      dfs(i, i, -1);
      if (flag == 0) ans = ans + 1;
    }
  }
  cout << ans << endl;
  return 0;
}
