#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
bool visited[100005];
int edge[100005];
int bfs(int src) {
  queue<int> q;
  q.push(src);
  int cc = 1, ec = 0;
  visited[src] = true;
  map<pair<int, int>, int> mpp;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < adj[u].size(); i++) {
      int v = adj[u][i];
      pair<int, int> p1 = make_pair(u, v);
      pair<int, int> p2 = make_pair(v, u);
      if (mpp[p1] == 0 && mpp[p2] == 0) {
        mpp[p1]++;
        mpp[p2]++;
        ec++;
      }
      if (visited[v] == false) {
        cc++;
        visited[v] = true;
        q.push(v);
      }
    }
  }
  if (ec < cc) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (__typeof(m) i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
    edge[x]++;
    edge[y]++;
  }
  int ans = 0;
  for (__typeof(n) i = 1; i <= n; i++) {
    if (visited[i] == false) {
      ans += bfs(i);
    }
  }
  cout << ans;
  return 0;
}
