#include <bits/stdc++.h>
using namespace std;
vector<int> v[100001];
bool vis[100001];
void dfs(int nod, int parent, int &flag) {
  int i;
  vis[nod] = 1;
  for (i = 0; i < v[nod].size(); i++) {
    int curr = v[nod][i];
    if (vis[curr] == 0) {
      dfs(curr, nod, flag);
    } else if (parent != curr) {
      flag = 1;
    }
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int cit, road, i, u1, v1;
  cin >> cit >> road;
  for (i = 1; i <= road; i++) {
    cin >> u1 >> v1;
    v[v1].push_back(u1);
    v[u1].push_back(v1);
  }
  int flag, cnt = 0, parent = -1;
  for (i = 1; i <= cit; i++) {
    flag = 0;
    if (vis[i] == 0) {
      dfs(i, parent, flag);
      if (flag == 0) {
        cnt++;
      }
    }
  }
  cout << cnt;
  return 0;
}
