#include <bits/stdc++.h>
using namespace std;
long long gcdx(long long a, long long b) { return b ? gcdx(b, a % b) : a; }
long long gcd(long long a, long long b) { return gcdx(abs(a), abs(b)); }
void setbit(int &m, int ind, int val) {
  if (val)
    m = (m | (1 << ind));
  else
    m = (m & ~(1 << ind));
}
bool getbit(int m, int ind) {
  int a = (1 << ind);
  a = (a & m);
  return a;
}
int cntbits(int m) {
  int ret = 0;
  while (m) {
    ret += (m % 2);
    m /= 2;
  }
  return ret;
}
bool isSmlltr(char c) {
  if (c >= 'a' && c <= 'z') return 1;
  return 0;
}
bool isCapltr(char c) {
  if (c >= 'A' && c <= 'Z') return 1;
  return 0;
}
const long long mod = 1000000007;
long long pow_mod(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2) return (a * pow_mod((a * a) % mod, b / 2)) % mod;
  return pow_mod((a * a) % mod, b / 2);
}
const long long mod2 = 998244353;
const long long mod3 = 1000000009;
int n, m, q, Q, x, y, z, t, cnt, tmp, maxi, ans;
bool vis[100100];
vector<int> v[100100];
pair<int, int> dfs(int node) {
  vis[node] = 1;
  int nodes = 1, edges = v[node].size();
  for (int i = 0; i < v[node].size(); i++) {
    int son = v[node][i];
    if (!vis[son]) {
      pair<int, int> temp = dfs(son);
      nodes += temp.first;
      edges += temp.second;
    }
  }
  return make_pair(nodes, edges);
}
int main() {
  scanf("%d %d", &n, &m);
  {
    for (int i = 0; i < m; i++) {
      int a, b;
      scanf("%d %d", &a, &b);
      {
        v[a].push_back(b);
        v[b].push_back(a);
      };
    };
  };
  ans = 0;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      pair<int, int> temp = dfs(i);
      if (temp.second / 2 < temp.first) ans++;
    }
  printf("%d ", ans);
  return 0;
}
