#include <bits/stdc++.h>
using namespace std;
int f = 0;
vector<int> g[100005];
bool vis[100005];
void dfs(int u, int parent) {
  vis[u] = true;
  for (int i = 0; i < g[u].size(); i++) {
    if (g[u][i] != parent) {
      if (!vis[g[u][i]])
        dfs(g[u][i], u);
      else
        f = 1;
    }
  }
  return;
}
int main() {
  int n, m, i, a, b, ans = 0;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (i = 1; i <= n; i++) {
    if (!vis[i]) {
      f = 0;
      dfs(i, -1);
      if (!f) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
