#include <bits/stdc++.h>
using namespace std;
bool myfunction(int i, int j) { return (i > j); }
bool visit[100000 + 5];
vector<long long int> graph[100000 + 5];
long long int ans;
void initialize(long long int n) {
  long long int i;
  for (i = 0; i < n + 2; i++) visit[i] = false;
}
void dfs(long long int s, long long int parent) {
  visit[s] = true;
  long long int i;
  for (i = 0; i < graph[s].size(); i++) {
    if (visit[graph[s][i]] == false) {
      dfs(graph[s][i], s);
    } else if (graph[s][i] != parent)
      ans = 1;
  }
  return;
}
int main() {
  long long int n, i, m;
  cin >> n >> m;
  long long int a, b;
  initialize(n);
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  a = 0;
  ans = 0;
  for (i = 1; i < n + 1; i++) {
    if (visit[i] == false) {
      dfs(i, 0);
      if (ans != 1) a++;
      ans = 0;
    }
  }
  cout << a;
}
