#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int vis[100100];
vector<int> g[100100];
int dfs(int node, int par = 0) {
  if (vis[node]) return 0;
  vis[node] = 1;
  int r = 1;
  for (int i = 0; i < g[node].size(); i++) {
    int child = g[node][i];
    if (child == par) continue;
    if (!dfs(child, node)) r = 0;
  }
  return r;
}
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int s = 0;
  for (int a = 1; a <= n; a++) {
    if (!vis[a]) s += dfs(a);
  }
  cout << s << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
}
