#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
void addEdge(int x, int y) {
  adj[x].push_back(y);
  adj[y].push_back(x);
}
bool visited[100005] = {false};
bool currentcycle[100005] = {false};
bool iscycle = false;
void dfs(int node, int parent) {
  visited[node] = true;
  currentcycle[node] = true;
  for (int i = 0; i < adj[node].size(); i++) {
    if (adj[node][i] != parent) {
      if (visited[adj[node][i]] == false) {
        dfs(adj[node][i], node);
      } else {
        if (currentcycle[adj[node][i]] == true) {
          iscycle = true;
        }
      }
    }
  }
  currentcycle[node] = false;
}
int main() {
  int answer = 0;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    addEdge(x, y);
  }
  for (int i = 1; i <= n; i++) {
    if (visited[i] == false) {
      dfs(i, -1);
      if (iscycle == false) answer += 1;
    }
    iscycle = false;
  }
  cout << answer;
}
