#include <bits/stdc++.h>
using namespace std;
int n, m;
int t, ch[100005];
vector<int> g[100005];
void dfs(int u, int fa) {
  ch[u] = 1;
  for (auto i : g[u]) {
    if (ch[i] == 0) {
      dfs(i, u);
    } else if (ch[i] == 1 && i != fa) {
      t = 1;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  memset(ch, 0, sizeof(ch));
  for (int i = 1; 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; i++) {
    if (ch[i] == 0) {
      t = 0;
      dfs(i, i);
      if (t == 0) ans++;
    }
  }
  cout << ans;
  return 0;
}
