#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 239;
int n, p[M];
int m;
vector<int> v[200050];
int vis[200050];
int x = 0;
void dfs(int i, int p) {
  vis[i] = 1;
  for (auto y : v[i]) {
    if (!vis[y]) {
      dfs(y, i);
    } else if (y != p) {
      x = 1;
    }
  }
}
void solve() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a = 0, b = 0;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    x = 0;
    if (!vis[i]) {
      dfs(i, -1);
      if (x == 0) {
        cnt++;
      }
    }
  }
  cout << cnt;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
