#include <bits/stdc++.h>
using namespace std;
void dfs(int i, vector<vector<int>> &graph, bool &flag, int parent,
         vector<bool> &visited) {
  int sz = graph[i].size();
  for (int j = 0; j < sz; j++) {
    if (graph[i][j] != parent) {
      if (visited[graph[i][j]])
        flag = true;
      else {
        visited[graph[i][j]] = true;
        dfs(graph[i][j], graph, flag, i, visited);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, a, b;
  cin >> n >> m;
  vector<vector<int>> graph(n + 1);
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  long long ans = 0;
  vector<bool> visited(n + 1, false);
  for (int f = 1; f <= n; f++) {
    if (graph[f].size() == 0) {
      ans++;
      continue;
    }
    if (!visited[f]) {
      bool flag = false;
      dfs(f, graph, flag, -1, visited);
      if (!flag) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
