#include <bits/stdc++.h>
using namespace std;
const long long MX = 1e5 + 1;
int n, m, ans;
vector<vector<int> > A(MX);
bool vis[MX];
bool solve(int i, int pre = -1) {
  if (vis[i]) return false;
  vis[i] = true;
  int ret = 1;
  for (int j = 0; j < (int)A[i].size(); ++j)
    if (A[i][j] != pre) ret = ret && solve(A[i][j], i);
  return ret;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int a, b;
    cin >> a >> b;
    A[a].push_back(b);
    A[b].push_back(a);
  }
  for (int i = 1; i <= n; ++i) ans += solve(i);
  cout << ans;
  return 0;
}
