#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
inline int in() {
  int n;
  scanf("%d", &n);
  return n;
}
const ll maxn = 1e5 + 1;
vector<int> adj[maxn];
bool visited[maxn];
bool dfs(int v, int p) {
  visited[v] = true;
  for (int u : adj[v]) {
    if (visited[u] and u != p) return true;
    if (!visited[u] and dfs(u, v)) return true;
  }
  return false;
}
int main() {
  int n = in(), m = in();
  for (int i = 0; i < m; i++) {
    int u = in() - 1, v = in() - 1;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int ans = 0;
  for (int v = 0; v < n; v++) {
    if (!visited[v]) dfs(v, -1) ? ans = ans : ans++;
  }
  cout << ans << '\n';
}
