#include <bits/stdc++.h>
using namespace std;
const int M = 100000 + 5;
vector<int> v[M];
bool vis[M];
bool f;
void dfs(int x, int w) {
  vis[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    int y = v[x][i];
    if (y == w) continue;
    if (vis[y] == 1) {
      f = 0;
      continue;
    }
    dfs(y, x);
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  f = 1;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      dfs(i, i);
      if (f) {
        ans++;
      }
      f = 1;
    }
  }
  printf("%d", ans);
  return 0;
}
