#include <bits/stdc++.h>
using namespace std;
vector<int> nodes[100001];
int flag = 0;
bool state[100001];
void dfs(int a, int par) {
  state[a] = true;
  for (int i = 0; i < nodes[a].size(); i++) {
    if (nodes[a][i] != par) {
      if (state[nodes[a][i]] == true)
        flag = 1;
      else
        dfs(nodes[a][i], a);
    }
  }
}
int main() {
  int n, e, u, v;
  cin >> n >> e;
  for (int i = 0; i < e; i++) {
    cin >> u >> v;
    nodes[u].push_back(v);
    nodes[v].push_back(u);
  }
  int count = 0;
  for (int i = 1; i <= n; i++) {
    if (state[i] == false) {
      flag = 0;
      dfs(i, -1);
      if (flag == 0) count++;
    }
  }
  cout << count << "\n";
}
