#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
const long long N = 1e5 + 5;
long long parent[N], size[N];
void make_set(long long v) {
  parent[v] = v;
  size[v] = 1;
}
long long find_set(long long v) {
  if (v == parent[v]) return v;
  return parent[v] = find_set(parent[v]);
}
void union_sets(long long a, long long b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (size[a] < size[b]) swap(a, b);
    parent[b] = a;
    size[a] += size[b];
  }
}
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<vector<long long>> v;
  v.resize(n);
  for (long long i = 0; i < n; i++) {
    make_set(i);
  }
  for (long long i = 0; i < k; i++) {
    long long x, y;
    cin >> x >> y;
    x--, y--;
    union_sets(x, y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  map<long long, long long> m;
  for (long long i = 0; i < n; i++) {
    m[find_set(i)] += v[i].size();
  }
  long long ans = 0;
  for (auto it : m) {
    if (size[it.first] > it.second / 2) ans++;
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
}
