#include <bits/stdc++.h>
using namespace std;
struct node {
  int s, t, next;
} p[1000000];
int fel[100001], v[100001], tot, n, m, x, y, ans, flag;
inline void add_edge(int s, int t) {
  p[tot].s = s, p[tot].t = t, p[tot].next = fel[s];
  fel[s] = tot++;
}
inline void init() {
  tot = 0;
  memset(fel, -1, sizeof(fel));
}
inline void dfs_1(int x, int last) {
  v[x] = 1;
  for (int i = fel[x], y = p[i].t; i != -1; i = p[i].next, y = p[i].t) {
    if (v[y] && last != y) flag = 0;
    if (!v[y]) dfs_1(y, x);
  }
}
int main() {
  init();
  scanf("%d%d", &n, &m);
  while (m--) scanf("%d%d", &x, &y), add_edge(x, y), add_edge(y, x);
  for (int i = 1; i <= n; i++)
    if (!v[i]) flag = 1, dfs_1(i, 0), ans += flag ? 1 : 0;
  printf("%d\n", ans);
}
