#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e5 + 5;
bool mark[maxx];
int ans = 0, num = 0;
int par[maxx], h[maxx], deg[maxx];
vector<int> v[maxx];
void dfs(int x) {
  mark[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    int child = v[x][i];
    if (mark[child] == 1 && h[child] < h[x] && child != par[x]) ans++;
    if (!mark[child]) {
      h[child] = h[x] + 1;
      par[child] = x;
      ans++;
      num++;
      dfs(child);
    }
  }
}
int main() {
  int n, m, answer = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int fi, se;
    cin >> fi >> se;
    v[fi].push_back(se);
    v[se].push_back(fi);
    deg[fi]++;
    deg[se]++;
  }
  for (int i = 1; i <= n; i++)
    if (!mark[i]) {
      ans = 0;
      num = 1;
      dfs(i);
      if (ans < num) answer++;
    }
  cout << answer;
}
