#include <bits/stdc++.h>
using namespace std;
struct Node {
  vector<int> arr;
};
bool cycle(vector<Node> &arr, vector<bool> &visited, int idx, int parent) {
  Node &n = arr[idx];
  int Q = n.arr.size();
  int flag = false;
  for (int q = (0); q < (Q); ++q) {
    int to = n.arr[q];
    if (to != parent) {
      if (visited[to]) {
        flag = true;
      } else {
        visited[to] = true;
        flag |= cycle(arr, visited, to, idx);
      }
    }
  }
  return flag;
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<Node> arr(N);
  vector<bool> vis(N, false);
  for (int n = (0); n < (M); ++n) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    arr[a].arr.push_back(b);
    arr[b].arr.push_back(a);
  }
  int sum = 0;
  for (int n = (0); n < (N); ++n) {
    if (!vis[n]) {
      vis[n] = true;
      sum += 1 - (cycle(arr, vis, n, n));
    }
  }
  cout << sum << endl;
  return 0;
}
