#include <bits/stdc++.h>
using namespace std;
int n, m, comp_num;
vector<vector<int> > g;
vector<bool> used;
vector<vector<int> > comp;
vector<long long int> dv;
vector<long long int> dv_in_comp;
vector<int> components;
void dfs(int v) {
  used[v] = true;
  comp[comp.size() - 1].push_back(v);
  dv_in_comp[dv_in_comp.size() - 1] += dv[v];
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (!used[to]) dfs(to);
  }
}
void find_comps() {
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      comp.push_back(vector<int>());
      dv_in_comp.push_back(0);
      dfs(i);
    }
  }
}
int main() {
  cin >> n >> m;
  g.resize(n);
  dv.resize(n, 0);
  used.resize(n, false);
  components.resize(n, -1);
  int ui, vi;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &ui, &vi);
    ui--;
    vi--;
    g[ui].push_back(vi);
    g[vi].push_back(ui);
    dv[ui]++;
    dv[vi]++;
  }
  find_comps();
  int total = 0;
  for (int i = 0; i < comp.size(); i++) {
    if (dv_in_comp[i] > 2 * (comp[i].size() - 1)) {
      total += 0;
    } else
      total++;
  }
  cout << total;
  return 0;
}
