#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, m;
vector<int> mp[maxn];
int dis[maxn];
int flag;
void dfs(int u, int from) {
  dis[u] = 1;
  for (int i = 0; i < mp[u].size(); i++) {
    int v = mp[u][i];
    if (v == from) continue;
    if (dis[v] == 1) {
      flag = 1;
      continue;
    }
    dfs(v, u);
  }
}
void init() {
  for (int i = 1; i <= n; i++) {
    mp[i].clear();
  }
}
int main() {
  int x, y;
  while (~scanf("%d %d", &n, &m)) {
    memset(dis, 0, sizeof(dis));
    init();
    for (int i = 0; i < m; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      mp[x].push_back(y);
      mp[y].push_back(x);
    }
    int ti = 0;
    for (int i = 1; i <= n; i++) {
      if (dis[i] == 0) {
        flag = 0;
        dfs(i, -1);
        if (flag == 0) ti++;
      }
    }
    printf("%d\n", ti);
  }
}
