#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
const int mod = 1e9 + 7;
const int B = sqrt(N);
int n, m;
int g;
int ans;
bool used[N];
vector<int> v[N];
void dfs(int x, int p) {
  used[x] = true;
  for (auto y : v[x]) {
    if (y == p) continue;
    if (used[y])
      g = 0;
    else
      dfs(y, x);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      g = 1;
      dfs(i, i);
      ans += g;
    }
  }
  cout << ans;
}
