#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, c[100500], ans;
vector<int> g[100500];
bool dfs(int v, int p = -1) {
  c[v] = 1;
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (to == p) continue;
    if (c[to] == 0) {
      if (dfs(to, v)) return true;
    } else if (c[to] == 1)
      return true;
  }
  c[v] = 2;
  return false;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 1; i <= n; ++i)
    if (c[i] == 0) ans += !dfs(i);
  cout << ans;
}
