#include <bits/stdc++.h>
using namespace std;
void detectCycle(int parent, int x, bool &hasCycle, vector<int> adjList[],
                 bool visited[]) {
  int neighbor;
  visited[x] = true;
  for (int i = 0; i < adjList[x].size(); i++) {
    neighbor = adjList[x][i];
    if (neighbor != parent && visited[neighbor])
      hasCycle = true;
    else if (!visited[neighbor])
      detectCycle(x, neighbor, hasCycle, adjList, visited);
  }
}
int main() {
  int n, m, i, x, y;
  cin >> n >> m;
  vector<int> adjList[n + 1];
  bool visited[n + 1];
  fill(visited + 1, visited + n + 1, false);
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    adjList[x].push_back(y);
    adjList[y].push_back(x);
  }
  bool cycle = false;
  int k = 0;
  for (i = 1; i <= n; i++) {
    if (!visited[i]) {
      cycle = false;
      detectCycle(-1, i, cycle, adjList, visited);
      if (!cycle) k++;
    }
  }
  cout << k;
  return 0;
}
