#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 9;
vector<int> adj[N];
int vis[N], finalvis[N], tarnode = 1;
vector<int> vec;
void dfs(int child, int par) {
  vis[child] = 1;
  for (auto node : adj[child]) {
    if (node != par and vis[node]) {
      tarnode = node;
      vec.push_back(tarnode);
    }
    if (node != par and !vis[node]) {
      dfs(node, child);
    }
  }
}
void dfs1(int child, int par) {
  for (auto node : adj[child]) {
    if (node != par and !finalvis[node]) {
      finalvis[node] = 1;
      dfs1(node, child);
    }
  }
}
int main() {
  int n, m, u, v;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) dfs(i, i);
  }
  for (auto val : vec) {
    dfs1(val, val);
  }
  for (int i = 1; i <= n; i++) {
    if (!finalvis[i]) dfs1(i, i);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (!finalvis[i]) ans++;
  cout << ans << endl;
}
