#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int N = 100007;
int n, vis[N];
vector<int> g[N];
bool dfs(int v, int p) {
  bool res = false;
  vis[v] = 1;
  for (auto u : g[v])
    if (u != p) {
      if (vis[u] == 1)
        res |= true;
      else
        res |= dfs(u, v);
    }
  return res;
}
void solve() {
  int m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int res = 0;
  for (int v = 1; v <= n; ++v) {
    if (vis[v] == 0) {
      if (!dfs(v, -1)) ++res;
    }
  }
  cout << res << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  solve();
  return 0;
}
