#include <bits/stdc++.h>
using namespace std;
vector<long long> g[100005];
bool vis[100005] = {0};
bool dfs(long long u, long long par) {
  vis[u] = 1;
  long long sz = g[u].size();
  for (long long i = (long long)(0); i <= (long long)(sz - 1); i++) {
    if (!vis[g[u][i]]) {
      if (dfs(g[u][i], u)) return 1;
    } else {
      if (g[u][i] != par) {
        return 1;
      }
    }
  }
  return 0;
}
int main() {
  std::ios::sync_with_stdio(false);
  long long n, m, a, b;
  cin >> n >> m;
  for (long long i = (long long)(1); i <= (long long)(m); i++) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  long long c = 0;
  for (long long i = (long long)(1); i <= (long long)(n); i++) {
    if (!vis[i]) {
      if (!dfs(i, -1)) c++;
    }
  }
  cout << c << endl;
  return 0;
}
