#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> g[100005];
vector<vector<int>> comps;
vector<int> counts;
bool visited[100005];
void dfs(int curr, bool first) {
  visited[curr] = true;
  if (first) {
    comps.push_back(vector<int>());
    counts.push_back(0);
  }
  comps[comps.size() - 1].push_back(curr);
  for (auto u : g[curr]) {
    counts[counts.size() - 1]++;
    if (!visited[u]) dfs(u, false);
  }
}
int main() {
  int a, b;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 1; i < n; ++i) {
    if (!visited[i]) dfs(i, true);
  }
  int c = 0;
  for (int i = 0; i < comps.size(); ++i) {
    if (counts[i] / 2 == comps[i].size() - 1)
      c += counts[i] / 2;
    else
      c += comps[i].size();
  }
  cout << n - c << endl;
  return 0;
}
