#include <bits/stdc++.h>
using namespace std;
long long mod = 10000000000;
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long fastexp(long long x, long long n) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result *= x;
    x *= x;
    n = n / 2;
  }
  return result;
}
long long modularExp(long long x, long long n, long long mod) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % mod;
    x = ((x % mod) * (x % mod)) % mod;
    n = n / 2;
  }
  return (result) % mod;
}
bool isPrime(long long n) {
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
bool mycomp(pair<long long, long long> &a, pair<long long, long long> &b) {
  if (a.first != b.first)
    return a.first < b.first;
  else
    return a.second < b.second;
}
vector<long long> v[100005], visited(100005);
long long dfs(long long node, long long par) {
  visited[node] = 1;
  long long x = 0;
  for (auto it : v[node]) {
    if (visited[it] && it != par)
      x += 1;
    else if (it == par)
      continue;
    else
      x += dfs(it, node);
  }
  if (x >= 1)
    return 1;
  else
    return 0;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  long long i;
  for (i = 1; i <= m; i++) {
    long long x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  long long ans = 0;
  for (i = 1; i <= n; i++) {
    if (!visited[i]) {
      if (!dfs(i, -1)) ans += 1;
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  long long i;
  t = 1;
  while (t--) {
    solve();
  }
}
