#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, INF = 1e18, mx = 1e5 + 5, mn = 100;
int testCase = 1, cas = 0;
vector<int> G[mx];
int n, m;
int vis[mx], par[mx], indegree[mx];
int ok;
void dfs(int u) {
  vis[u]++;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (!vis[v]) {
      par[v] = u;
      indegree[v]++;
      dfs(v);
    } else if (par[u] != v)
      ok = 1;
  }
}
int main() {
  ios_base ::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      ok = 0;
      dfs(i);
      if (!ok) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
