#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
vector<int> g[100005];
int vs[100005];
int p[100005];
int t = 1;
int mk;
void dfs(int u) {
  vs[u] = 1;
  for (int i = 0; i < (int)(g[u].size()); i++) {
    int w = g[u][i];
    if (!vs[w]) {
      p[w] = u;
      dfs(w);
    } else if (vs[w] and w != p[u]) {
      mk = 1;
    }
  }
}
int main() {
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (!vs[i]) {
      mk = 0;
      dfs(i);
      if (!mk) {
        cnt++;
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}
