#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
vector<int> G[MAXN + 7];
bool vis[MAXN + 7];
bool OK = false;
void DFS(int x, int f) {
  vis[x] = true;
  for (int i = 0; i < G[x].size(); i++) {
    if (!vis[G[x][i]])
      DFS(G[x][i], x);
    else if (vis[G[x][i]] && G[x][i] != f)
      OK = true;
  }
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    OK = false;
    if (!vis[i]) {
      DFS(i, 0);
      if (!OK) ans++;
    }
  }
  printf("%d", ans);
  return 0;
}
