#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
vector<long long> g[400000];
long long par[400000];
bool w[400000];
bool cyc = false;
void dfs(int v, int parent) {
  w[v] = true;
  for (int i = 0; i < g[v].size(); ++i) {
    int cur = g[v][i];
    if (!w[cur])
      dfs(cur, v);
    else if (cur != parent)
      cyc = true;
  }
}
int main(void) {
  ios_base::sync_with_stdio(false);
  for (int i = 0; i < 200000; ++i) par[i] = -1;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 0; i < n; ++i) {
    cyc = false;
    if (!w[i]) {
      dfs(i, -1);
      if (cyc == false) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
