#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int n, m, used[N], ans;
vector<int> g[N];
bool cycle;
void dfs(int v, int p = -1) {
  used[v] = 1;
  for (auto to : g[v]) {
    if (to == p) continue;
    if (used[to] == 1) cycle = 1;
    if (used[to] == 0) dfs(to, v);
  }
  used[v] = 2;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 1; i <= n; i++)
    if (used[i] == 0) {
      cycle = 0;
      dfs(i);
      if (!cycle) ans++;
    }
  cout << ans;
  return 0;
}
