#include <bits/stdc++.h>
using namespace std;
long long cmax(long long a, long long b) { return (a > b ? a : b); }
long long cmax(long long a, long long b, long long c) {
  return cmax(cmax(a, b), c);
}
long long cmin(long long a, long long b) { return (a < b ? a : b); }
long long cmin(long long a, long long b, long long c) {
  return cmin(cmin(a, b), c);
}
void dfs(vector<long long> *g, bool *v, long long curr, long long p,
         long long &cycle) {
  v[curr] = true;
  for (long long i = 0; i < g[curr].size(); i++) {
    if (v[g[curr][i]]) {
      if (g[curr][i] != p) {
        cycle = 1;
      }
    } else {
      dfs(g, v, g[curr][i], curr, cycle);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<long long> *g = new vector<long long>[n + 1];
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  bool *v = new bool[n + 1];
  for (long long i = 1; i <= n; i++) {
    v[i] = false;
  }
  bool done = false;
  long long ans = 0, first_unv = 1;
  while (!done) {
    long long cycle = 0;
    dfs(g, v, first_unv, -1, cycle);
    ans += !cycle;
    while (v[first_unv]) {
      ++first_unv;
      if (first_unv == n + 1) {
        done = true;
        break;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
