#include <bits/stdc++.h>
using namespace std;
vector<long long> v[100000 + 1];
long long n, m;
long long taken[100000 + 1];
map<int, int> v2;
int check = 0, sum;
void bfs() {
  queue<long long> q;
  long long j, x, y;
  for (int i = 1; i <= n; i++) {
    if (taken[i] == 0) {
      q.push(i);
      check = 0;
      while (!q.empty()) {
        x = q.front();
        q.pop();
        v2[x] = 1;
        for (j = 0; j < v[x].size(); j++) {
          y = v[x][j];
          if (taken[y] == 0) {
            q.push(y);
            taken[y] = 1;
          } else if (taken[y] == 1 && v2[y] == 0) {
            check = 1;
          }
        }
      }
      if (check == 0) {
        sum = sum + 1;
      }
    }
  }
}
int main() {
  long long i, x, y;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  sum = 0;
  bfs();
  cout << sum << "\n";
}
