#include <bits/stdc++.h>
using namespace std;
bool visited[100010];
list<long long int> l[100010];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  memset(visited, 0, sizeof(visited));
  long long int n, m;
  cin >> n >> m;
  long long int i, x, y, ans = 0;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    l[x].push_back(y);
    l[y].push_back(x);
  }
  bool cycle;
  for (i = 0; i < n; i++) {
    if (visited[i]) continue;
    pair<long long int, long long int> p1, p2;
    stack<pair<long long int, long long int> > s;
    s.push(make_pair(i, -1ll));
    cycle = 0;
    while (!s.empty()) {
      p1 = s.top();
      s.pop();
      if (!visited[p1.first]) {
        visited[p1.first] = 1;
        list<long long int>::iterator it;
        for (it = l[p1.first].begin(); it != l[p1.first].end(); it++) {
          if (visited[*it]) {
            if (*it != p1.second) {
              cycle = 1;
            }
          } else {
            s.push(make_pair(*it, p1.first));
          }
        }
      }
    }
    if (!cycle) ans++;
  }
  cout << ans << endl;
  return 0;
}
