#include <bits/stdc++.h>
using namespace std;
const int N = 112345;
vector<int> v[N];
bool used[N];
bool ok = 0;
void dfs(int x, int p) {
  used[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    int to = v[x][i];
    if (!used[to]) {
      dfs(to, x);
    } else {
      if (to != p && p != -1) {
        ok = 1;
      }
    }
  }
}
int main() {
  int n, m, i, j, x, y;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    scanf("%d %d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  int cnt = 0;
  for (i = 1; i <= n; i++) {
    if (!used[i]) {
      ok = 0;
      dfs(i, -1);
      if (!ok) cnt++;
    }
  }
  cout << cnt;
}
