#include <bits/stdc++.h>
using namespace std;
vector<long long int> friends[100005];
long long int visited[100005];
bool cycle;
long long int reckstack[100005];
void dfs(long long int i, long long int parent) {
  visited[i] = true;
  reckstack[i] = true;
  for (long long int y : friends[i]) {
    if (!visited[y]) {
      dfs(y, i);
    }
    if (visited[y] && reckstack[y] == 1 && y != parent) {
      cycle = true;
    }
  }
  reckstack[i] = false;
}
int32_t main() {
  long long int N;
  cin >> N;
  long long int M;
  cin >> M;
  for (long long int i = 0; i < M; i++) {
    long long int a;
    cin >> a;
    long long int b;
    cin >> b;
    a--;
    b--;
    friends[a].push_back(b);
    friends[b].push_back(a);
  }
  memset(visited, 0, sizeof(visited));
  memset(reckstack, 0, sizeof(reckstack));
  long long int sum = 0;
  for (long long int i = 0; i < N; i++) {
    cycle = false;
    if (!visited[i]) {
      dfs(i, -1);
      if (!cycle) {
        sum++;
      }
    }
  }
  cout << sum << endl;
}
