#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 1e5 + 5;
int ans, c;
vector<int> v[N];
bool vis[N];
void dfs(int s, int p) {
  vis[s] = true;
  for (auto e : v[s]) {
    if (!vis[e])
      dfs(e, s);
    else if (e != p)
      c = 0;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, x, y;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      c = 1;
      dfs(i, -1);
      ans += c;
    }
  }
  cout << ans;
  return 0;
}
