#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const long long mod = 1e9 + 7;
const int max_n = 1000100;
bool vis[100100] = {0};
int par[100100];
vector<int> g[100100];
bool ok;
void dfs(int x) {
  vis[x] = 1;
  for (int i = 0; i < g[x].size(); i++) {
    if (!vis[g[x][i]]) {
      par[g[x][i]] = x;
      dfs(g[x][i]);
    } else {
      if (g[x][i] != par[x]) ok = true;
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int x, y;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ok = false;
    if (!vis[i]) {
      par[i] = -1;
      dfs(i);
      if (!ok) ++ans;
    }
  }
  cout << ans << endl;
}
