#include <bits/stdc++.h>
using namespace std;
struct Node {
  Node() : vis(0), comp(-1) {}
  int vis;
  int comp;
  vector<int> adj;
};
void dfs(vector<Node>& a, int u, int comp) {
  a[u].vis = true;
  a[u].comp = comp;
  for (auto v : a[u].adj) {
    if (a[v].vis == false) {
      dfs(a, v, comp);
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<Node> a(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    a[u - 1].adj.push_back(v - 1);
    a[v - 1].adj.push_back(u - 1);
  }
  int comp = 0;
  for (int i = 0; i < n; i++) {
    if (a[i].vis == 0) {
      dfs(a, i, comp++);
    }
  }
  int res = 0;
  vector<pair<int, int>> comps(comp);
  for (int i = 0; i < n; i++) {
    comps[a[i].comp].first += a[i].adj.size();
    comps[a[i].comp].second++;
  }
  for (int i = 0; i < comps.size(); i++) {
    if (2 * comps[i].second - comps[i].first > 0) res++;
  }
  cout << res << endl;
  return 0;
}
