#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 500;
int n, m, vis[maxn], dfn[maxn], low[maxn], have, dfs_clock;
vector<int> G[maxn];
stack<int> s;
void dfs(int x, int y) {
  dfn[x] = low[x] = ++dfs_clock;
  s.push(x);
  for (auto it : G[x]) {
    if (it == y) continue;
    if (!dfn[it]) {
      dfs(it, x);
      low[x] = min(low[x], low[it]);
    } else
      low[x] = min(low[x], dfn[it]);
  }
  if (low[x] == dfn[x]) {
    int cnt = 0;
    while (1) {
      int u = s.top();
      s.pop();
      cnt++;
      if (u == x) break;
    }
    if (cnt > 1) have = 1;
  }
}
int main(int argc, char *argv[]) {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) {
      have = 0;
      dfs(i, -1);
      if (!have) ans++;
    }
  cout << ans << endl;
  return 0;
}
