#include <bits/stdc++.h>
using namespace std;
long long thien, used[300001], n, m, u, v, kq, tmp;
vector<long long> g[300001];
void dfs(long long u) {
  for (long long ii = 0; ii < g[u].size(); ii++) {
    v = g[u][ii];
    if (used[v] == 0) {
      used[v] = u;
      tmp = u;
      dfs(v);
    } else if (used[u] != v) {
      thien = 0;
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (long long i = 1; i <= n; i++) {
    thien = 1;
    tmp = -1;
    if (used[i] == 0) {
      used[i] = -1;
      dfs(i);
      kq += thien;
    }
  }
  cout << kq;
}
