#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long l, r, n, m, k, s, ans, ln, w, h, T, TT, x[1000001], y[1000001];
bool tt[1000001], ttt;
vector<long long> c[200001];
template <typename BRUH>
inline BRUH sqr(BRUH x) {
  return x * x;
}
long long binpow(long long h, long long r) {
  long long l = 1;
  while (r) {
    if (r & 1) l *= h, l %= MOD;
    h *= h;
    h %= MOD;
    r /= 2;
  }
  return l;
}
void dfs(int h) {
  T++;
  tt[h] = 1;
  TT += c[h].size();
  for (int i = 0; i < c[h].size(); i++)
    if (!tt[c[h][i]]) {
      dfs(c[h][i]);
    }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    c[x].push_back(y);
    c[y].push_back(x);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    if (!tt[i]) {
      T = 0;
      TT = 0;
      dfs(i);
      ans += max(T - TT / 2, 0ll);
    }
  cout << ans;
  return 0;
}
