#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};
int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
vector<int> adj[100005];
bool vis[100005];
vector<vector<int> > v;
vector<int> vv;
void dfs(int x) {
  vis[x] = 1;
  vv.push_back(x);
  for (int i = 0; i < adj[x].size(); i++)
    if (!vis[adj[x][i]]) dfs(adj[x][i]);
}
int main() {
  int n, m, ans = 0;
  scanf("%d%d", &n, &m);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      vv.clear();
      dfs(i);
      v.push_back(vv);
    }
  }
  for (int i = 0; i < v.size(); i++) {
    int c = 0;
    for (int j = 0; j < v[i].size(); j++) c += adj[v[i][j]].size();
    ans += (c < v[i].size() * 2);
  }
  printf("%d\n", ans);
  return 0;
}
