#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100001];
bool visited[100001];
void add_edge(int a, int b) {
  adj[a].push_back(b);
  adj[b].push_back(a);
}
bool DFS(int cur, int last) {
  visited[cur] = true;
  for (int i = 0; i < adj[cur].size(); i++) {
    if (visited[adj[cur][i]] == false) {
      bool getdfs = DFS(adj[cur][i], cur);
      if (getdfs == true) {
        return true;
      }
    } else if (adj[cur][i] != last) {
      return true;
    }
  }
  return false;
}
int n, m, ans;
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int ta, tb;
    cin >> ta >> tb;
    add_edge(ta, tb);
  }
  for (int i = 1; i <= n; i++) {
    if (visited[i] == false) {
      bool cset = DFS(i, -1);
      if (cset != true) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
