#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > roads;
int vis[111111];
bool ret = 1;
void Dfs(int po, int p) {
  if (vis[po]) return;
  vis[po] = 1;
  for (int i = 0; i < roads[po].size(); i++) {
    if (vis[roads[po][i]] && roads[po][i] != p) ret = 0;
    if (!vis[roads[po][i]]) Dfs(roads[po][i], po);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  roads.resize(n + 1);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    roads[x].push_back(y);
    roads[y].push_back(x);
  }
  int res = 0;
  for (int i = 1; i <= n; i++) {
    {
      if (!vis[i]) {
        ret = 1;
        Dfs(i, i);
        res += ret;
      }
    }
  }
  cout << res << endl;
  return 0;
}
