#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3fffffff;
int father[maxn], cnt[maxn];
int k[maxn], l[maxn];
int n, m;
void initial() {
  for (int i = 1; i <= maxn; i++) father[i] = i;
}
int findFather(int x) {
  int a = x;
  while (x != father[x]) x = father[x];
  while (a != father[a]) {
    int z = a;
    a = father[a];
    father[z] = x;
  }
  return x;
}
void Union(int a, int b) {
  int faA = findFather(a);
  int faB = findFather(b);
  if (faA != faB) father[faA] = faB;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  initial();
  cin >> n >> m;
  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    cnt[a]++;
    cnt[b]++;
    Union(a, b);
  }
  for (int i = 1; i <= n; i++) {
    int temp = findFather(i);
    k[temp]++;
    l[temp] += cnt[i];
  }
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (k[i] != 0)
      if (k[i] > l[i] / 2) res++;
  }
  cout << res;
  return ~~(0 - 0);
}
