#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int p[maxn], vis[maxn];
int find(int x) {
  if (x != p[x])
    return p[x] = find(p[x]);
  else
    return x;
}
void join(int x, int y) {
  int n = find(x), m = find(y);
  if (n != m) {
    p[n] = m;
    if (vis[n] || vis[m] || vis[x] || vis[y]) {
      vis[n] = vis[m] = vis[x] = vis[y] = 1;
    }
  } else
    vis[n] = vis[m] = vis[x] = vis[y] = 1;
}
int main() {
  ios::sync_with_stdio(false);
  int n, m, a, b, sum = 0;
  cin >> n >> m;
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    join(a, b);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i] && p[i] == i) sum++;
  }
  cout << sum << endl;
  return 0;
}
