#include <bits/stdc++.h>
using namespace std;
const int N = 3e5;
int n, m, ans;
int is[N];
vector<int> g[N];
int cur;
void dfs(int u, int p = -1) {
  is[u] = 1;
  for (int to : g[u]) {
    if (is[to] && to != p) {
      cur = 1;
    }
    if (!is[to]) dfs(to, u);
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (!is[i]) {
      cur = 0;
      dfs(i);
      ans += (cur ^ 1);
    }
  }
  cout << ans << '\n';
}
