#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int N = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)2e7;
const long long BIG = 1e18;
int used[N], cycle = 0;
vector<vector<int> > g(N);
void dfs(int v, int p = -1) {
  used[v] = 1;
  for (auto to : g[v]) {
    if (used[to] == 1)
      if (to != p) cycle = 1;
    if (used[to] == 0) dfs(to, v);
  }
  used[v] = 2;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v), g[v].push_back(u);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      cycle = 0;
      dfs(i);
      ans += !cycle;
    }
  }
  cout << ans;
  return 0;
}
