#include <bits/stdc++.h>
using namespace std;
int belong[100010];
vector<int> sz;
vector<int> near[100010];
void dfs(int cur) {
  if (belong[cur]) return;
  belong[cur] = sz.size();
  sz.back() += 2;
  for (auto x : near[cur]) dfs(x);
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    near[u].push_back(v);
    near[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (!belong[i]) {
      sz.push_back(0);
      dfs(i);
    }
  }
  for (int i = 1; i <= n; i++) sz[belong[i] - 1] -= near[i].size();
  int res = 0;
  for (auto x : sz)
    if (x > 0) res++;
  cout << res << endl;
  return 0;
}
