#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100001;
const long long MOD = 1000000007;
const long long INF = 1e18;
int par[MAX_N], ans[MAX_N], sz[MAX_N];
int rt(int v) { return ((par[v] == v) ? (v) : (par[v] = rt(par[v]))); }
void join(int u, int v) {
  ans[rt(v)]++;
  if ((u = rt(u)) != (v = rt(v))) par[u] = v, ans[v] += ans[u], sz[v] += sz[u];
}
int n, m;
bitset<MAX_N> vis;
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  for (int i = (0); i < (n); i++) par[i] = i, sz[i] = 1;
  for (int i = (0); i < (m); i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    join(a, b);
  }
  int num = 0;
  for (int i = (0); i < (n); i++) {
    if (vis[rt(i)]) continue;
    vis[rt(i)] = 1;
    num += max(sz[rt(i)] - ans[rt(i)], 0);
  }
  cout << num << endl;
  return 0;
}
