#include <bits/stdc++.h>
using namespace std;
const int N = 100001, M = N << 1;
int n, m, fa[N], ans, f, head[N], cnt, siz[N], vis[N], sum;
struct edge {
  int to, nex;
} t[M];
inline void add(int x, int y) {
  t[++cnt].to = y;
  t[cnt].nex = head[x];
  head[x] = cnt;
  return;
}
void dfs(int x, int bb) {
  vis[x] = 1;
  for (int i = head[x]; i; i = t[i].nex) {
    int y = t[i].to;
    if (y == bb) continue;
    if (vis[y]) {
      f = 1;
      continue;
    }
    vis[y] = 1;
    dfs(y, x);
  }
  return;
}
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool f = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return f ? x : -x;
}
int main() {
  n = read();
  m = read();
  for (int i = 1, u, v; i <= m; i++) {
    u = read();
    v = read();
    add(u, v);
    add(v, u);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      f = 0;
      dfs(i, 0);
      if (f == 0) ans++;
    }
  }
  cout << ans;
  return 0;
}
