#include <bits/stdc++.h>
using namespace std;
int long long n, m, cycle = 0, x, y;
vector<vector<int long long> > a;
vector<int long long> vis;
void dfs(int long long i, int long long path) {
  vis[i] = 1;
  int long long to;
  for (long long j = 0; j < a[i].size(); j++) {
    to = a[i][j];
    if (vis[to] == 1 && path != to)
      cycle = 1;
    else if (vis[to] != 1)
      dfs(to, i);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int long long ans = 0;
  cin >> n >> m;
  a.resize(n);
  vis.resize(n, 0);
  for (long long i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    a[y].push_back(x);
    a[x].push_back(y);
  }
  for (long long i = 0; i < n; i++) {
    cycle = 0;
    if (vis[i] == 0) {
      dfs(i, -1);
      ans += 1 - cycle;
    }
  }
  cout << ans << endl;
}
