#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int p[N];
int cycle[N];
int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }
bool join(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y) return false;
  if (rand() & 1) swap(x, y);
  p[x] = y;
  cycle[y] |= cycle[x];
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  for (int _n(N), i(0); i < _n; i++) p[i] = i;
  int n, m;
  cin >> n >> m;
  for (int _n(m), i(0); i < _n; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    if (!join(x, y)) {
      cycle[root(x)] = 1;
    }
  }
  set<int> s;
  for (int _n(n), i(0); i < _n; i++) s.insert(root(i));
  int ans = (int)s.size();
  for (int x : s) ans -= cycle[x];
  cout << ans << endl;
  return 0;
}
