#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[100001];
bool visited[100001];
bool recStack[100001];
vector<long long> p(100001, -1);
vector<long long> rnk(100001, -1);
void create_set(int x) {
  visited[x] = 1;
  p[x] = x;
  rnk[x] = 0;
}
int find_set(int i) {
  if (p[i] != i) p[i] = find_set(p[i]);
  return p[i];
}
void merge_set(int x, int y) {
  int px = find_set(x);
  int py = find_set(y);
  if (rnk[px] > rnk[py])
    p[py] = px;
  else
    p[px] = py;
  if (rnk[px] == rnk[py]) rnk[py] = rnk[py] + 1;
}
bool dfs(long long node, long long parent) {
  visited[node] = 1;
  for (auto i : adj[node]) {
    if (!visited[i]) {
      if (dfs(i, node)) return true;
    } else if (i != parent)
      return true;
  }
  return false;
}
int main() {
  iostream::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, m;
  cin >> n >> m;
  for (long long i = (0); i < (m); ++i) {
    long long a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  long long cnt = 0;
  memset(visited, 0, sizeof(visited));
  for (long long i = (1); i < (n + 1); ++i) {
    if (!visited[i]) {
      if (dfs(i, 0) == 0) cnt++;
    }
  }
  cout << cnt;
}
