#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100001];
bool vis[100001]{};
int p[100001];
bool fill(int v) {
  queue<int> q;
  vis[v] = 1;
  q.push(v);
  p[v] = -1;
  bool cicle = 0;
  while (!q.empty()) {
    v = q.front();
    q.pop();
    for (int u : adj[v]) {
      if (vis[u])
        cicle = cicle || (p[v] != u);
      else {
        vis[u] = 1;
        q.push(u);
        p[u] = v;
      }
    }
  }
  return !cicle;
}
int main() {
  int n, m;
  cin >> n >> m;
  while (m--) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      cnt += fill(i);
    }
  }
  cout << cnt << '\n';
  return 0;
}
