#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
bool mark[N];
vector<int> G[N];
bool DFS(int r, int pr) {
  mark[r] = true;
  for (int u : G[r])
    if (!mark[u]) {
      if (DFS(u, r)) return true;
    } else if (u != pr)
      return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  while (m--) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    G[x].push_back(y), G[y].push_back(x);
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
    if (!mark[i]) ans += (!DFS(i, -1));
  cout << ans << '\n';
  return 0;
}
