#include <bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
const double PI = acos(-1.0);
const double e = 2.718281828459;
const int mod = 1000000007;
vector<int> vc[100005];
int vis[100005];
int ans, s;
void dfs(int pos, int pre) {
  if (vis[pos]) {
    ans = 0;
    return;
  }
  vis[pos] = 1;
  for (int i = 0; i < vc[pos].size(); ++i) {
    if (vc[pos][i] != pre) dfs(vc[pos][i], pos);
  }
}
int main() {
  int n, m, i, j;
  int x, y;
  while (~scanf("%d%d", &n, &m)) {
    for (i = 1; i <= n; ++i) vc[i].clear();
    for (i = 1; i <= m; ++i) {
      scanf("%d%d", &x, &y);
      vc[x].push_back(y);
      vc[y].push_back(x);
    }
    s = 0;
    memset(vis, 0, sizeof(vis));
    for (i = 1; i <= n; ++i) {
      ans = 1;
      if (!vis[i]) {
        dfs(i, 0);
        s += ans;
      }
    }
    printf("%d\n", s);
  }
}
