#include <bits/stdc++.h>
using namespace std;
long long n, m = 0, k = 0;
bool test = false, test1 = false;
long long const N = 1e5 + 7;
bool check(int p, int n) {
  int temp = p, count = 0, f = 5;
  while (f <= temp) {
    count += temp / f;
    f = f * 5;
  }
  return (count >= n);
}
int findNum(int n) {
  if (n == 1) return 5;
  int low = 0;
  int high = 5 * n;
  while (low < high) {
    int mid = (low + high) >> 1;
    if (check(mid, n))
      high = mid;
    else
      low = mid + 1;
  }
  return low;
}
long long const oo = 1000000007;
long long nChoosek(long long n, long long k) {
  if (k > n) return 0;
  if (k * 2 > n) k = n - k;
  if (k == 0) return 1;
  long long result = n;
  for (long long i = 2; i <= k; ++i) {
    result *= (n - i + 1);
    result /= i;
  }
  return result;
}
vector<long long> v, v1;
vector<pair<long long, long long> > vv;
map<long long, long long> my;
map<long long, long long> my1;
priority_queue<long long> q;
long long t[N];
long long t1[N];
long long dx[4] = {0, 1, 0, -1};
long long dy[4] = {1, 0, -1, 0};
bool in_da_prison(long long x, long long y) {
  return (x < 9 && x >= 0 && y < 9 && y >= 0);
}
long long dp(long long i) {
  if (i == 0) return 1;
  if (i < 0) return 0;
  if (t[i] != -1) return t[i];
  long long choice1 = dp(i - 1) % oo;
  long long choice2 = dp(i - k) % oo;
  return t[i] = (choice1 % oo + choice2 % oo) % oo;
}
vector<long long> v2[N];
long long z[N], pr[N];
void dfs(long long s) {
  if (z[s]) return;
  z[s] = 1;
  for (long long u = 0; u < v2[s].size(); u++) {
    if (!z[v2[s][u]])
      pr[v2[s][u]] = s;
    else {
      if (pr[s] != v2[s][u]) test = true;
    }
    dfs(v2[s][u]);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long i = 0, j = 0, a = 0, b = 0, c = 0, d = 1e10, x = 0, y = 0, s = 0, t;
  string s1, s2, s3, s4, s5;
  cin >> n >> m;
  memset(pr, -1, sizeof pr);
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    a--;
    b--;
    v2[a].push_back(b);
    v2[b].push_back(a);
  }
  for (i = 0; i < n; i++) {
    test = false;
    if (!z[i]) {
      dfs(i);
      if (!test) s++;
    }
  }
  cout << s;
  return 0;
}
