#include <bits/stdc++.h>
using namespace std;
const long long inf = 1000000007LL;
const double EPS = 1e-14;
const long long inf_ll = (long long)1e18;
const long long maxn = 100005LL;
const long long maxm = 100005LL;
const long long mod = 1000000007LL;
struct Graph {
  struct edge {
    int u, v, nxt;
    edge(int nu = 0, int nv = 0, int nnxt = 0) : u(nu), v(nv), nxt(nnxt) {}
  } E[maxm * 2];
  int cnt, head[maxn];
  inline void link(int u, int v) {
    E[++cnt] = edge(u, v, head[u]);
    head[u] = cnt;
    E[++cnt] = edge(v, u, head[v]);
    head[v] = cnt;
  }
} G;
int n, m;
int vis[maxn];
int ans;
int dfs(int u, int p) {
  vis[u] = 1;
  for (register int(i) = G.head[u], (v) = G.E[i].v; (i);
       (i) = G.E[i].nxt, (v) = G.E[i].v) {
    if (v != p && vis[v]) return 1;
    if (v == p) continue;
    if (dfs(v, u)) return 1;
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (register int(i) = (1); (i) <= (m); ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    G.link(u, v);
  }
  for (register int(i) = (1); (i) <= (n); ++i)
    if (!vis[i] && !dfs(i, 0)) ++ans;
  printf("%d\n", ans);
  return 0;
}
