#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int>> graph;
vector<bool> is_visited;
vector<int> parent;
bool is_cyclic(int source) {
  is_visited[source] = true;
  queue<int> q;
  q.push(source);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v : graph[u]) {
      if (is_visited[v] && parent[u] != v) return true;
      if (!is_visited[v]) {
        is_visited[v] = true;
        parent[v] = u;
        q.push(v);
      }
    }
  }
  return false;
}
int get_min_sep_cities() {
  int min_sep_cities = 0;
  for (int i = 0; i < n; i++) {
    if (!is_visited[i]) {
      if (!is_cyclic(i)) min_sep_cities++;
    }
  }
  return min_sep_cities;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  graph.resize(n);
  is_visited.resize(n);
  parent.resize(n);
  fill(parent.begin(), parent.end(), -1);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  cout << get_min_sep_cities() << '\n';
  return 0;
}
