#include <bits/stdc++.h>
using namespace std;
vector<int> v[100001];
vector<int> par(100001);
int ans = 0;
bool dfs(int src, bool visited[]) {
  visited[src] = true;
  bool flag = false;
  int j;
  for (j = 0; j < v[src].size(); j++) {
    if (visited[v[src][j]] == false) {
      par[v[src][j]] = src;
      bool curr = dfs(v[src][j], visited);
      flag = flag || curr;
    } else if (v[src][j] != par[src]) {
      flag = true;
    }
  }
  return flag;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  bool visited[n + 1];
  memset(visited, false, sizeof(visited));
  for (int i = 1; i <= n; i++) {
    if (visited[i] == false) {
      par[i] = -1;
      bool x = dfs(i, visited);
      if (!x) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
