#include <bits/stdc++.h>
using namespace std;
int dfs_(int n, vector<vector<int>> &adj_list) {
  set<int> unvisited;
  for (int i = 1; i <= n; i++) unvisited.insert(i);
  int count = 0;
  while (!unvisited.empty()) {
    auto iter_set = unvisited.begin();
    int start_node = *iter_set;
    bool cycle = 0;
    stack<int> st;
    st.push(start_node);
    unvisited.erase(start_node);
    int prev_node = start_node;
    while (!st.empty()) {
      int cur_node = st.top();
      st.pop();
      for (auto &iter : adj_list[cur_node]) {
        if (unvisited.find(iter) != unvisited.end()) {
          st.push(iter);
          prev_node = iter;
          unvisited.erase(iter);
        } else if (iter != prev_node && iter != start_node) {
          cycle = true;
        }
      }
      prev_node = cur_node;
    }
    if (!cycle) count++;
  }
  return count;
}
bool visited[100001];
int levels[100001];
int temp_count = 0;
int res_count = 0;
void dfs(int src, vector<vector<int>> &adj_list) {
  visited[src] = true;
  for (auto &iter : adj_list[src]) {
    if (!visited[iter]) {
      levels[iter] = levels[src] + 1;
      dfs(iter, adj_list);
    } else if (levels[iter] > levels[src] + 1) {
      temp_count++;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  int x, y;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) visited[i] = false;
  for (int i = 1; i <= n; i++) levels[i] = 0;
  vector<vector<int>> adj_list(n + 1);
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    adj_list[x].push_back(y);
    adj_list[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      temp_count = 0;
      dfs(i, adj_list);
      if (temp_count == 0) res_count++;
    }
  }
  cout << res_count << endl;
}
