#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n, m;
set<int> graf[MAXN];
int deg[MAXN];
bool ok[MAXN];
void dfs(int node) {
  int ne = *graf[node].begin();
  ok[node] = true;
  deg[node] = 0;
  graf[node].clear();
  deg[ne]--;
  graf[ne].erase(node);
  if (deg[ne] == 1) dfs(ne);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    deg[x]++;
    graf[x].insert(y);
    deg[y]++;
    graf[y].insert(x);
  }
  for (int i = 0; i < n; ++i) {
    if (deg[i] == 1 && !ok[i]) {
      dfs(i);
    }
  }
  int sol = 0;
  for (int i = 0; i < n; ++i) {
    if (!deg[i] && !ok[i]) {
      sol++;
    }
  }
  printf("%d", sol);
}
