#include <bits/stdc++.h>
using namespace std;
const int MAXN = 0x3f3f3f3f;
const int MAXL = 0x7ffff;
inline void read(int &x) {
  x = 0;
  char c = getchar();
  while (c > '9' || c < '0') c = getchar();
  while (c <= '9' && c >= '0') {
    x = x * 10 + c - '0';
    c = getchar();
  }
}
inline void write(int re) {
  if (re > 9) write(re / 10);
  putchar(re % 10 + '0');
}
int ans, fat[100010], n, m;
bool vis[100100];
inline int find(register int x) {
  if (x == fat[x]) return x;
  return fat[x] = find(fat[x]);
}
int main() {
  read(n);
  read(m);
  ans = n;
  for (register int i = 0; i <= n; i++) fat[i] = i;
  for (register int i = 0; i < m; i++) {
    register int a, b;
    read(a);
    read(b);
    register int fa = find(a);
    register int fb = find(b);
    if (fa == fb && !vis[fa]) {
      ans--;
      vis[fa] = 1;
    } else if (fa != fb) {
      ans--;
      if (vis[fa] == 1 && vis[fb] == 1) ans++;
      if (vis[fa] == 1 || vis[fb] == 1) vis[fa] = 1, vis[fb] = 1;
      fat[fb] = fa;
    }
  }
  if (ans >= 0)
    cout << ans;
  else
    cout << 0;
}
