#include <bits/stdc++.h>
using namespace std;
vector<long long int> adj[100001];
bool visited[100001];
long long int n, m;
int flag;
void dfs(int parent, int vertex) {
  visited[vertex] = true;
  int i;
  for (i = 0; i < (long long int)(adj[vertex].size()); i++) {
    if (visited[adj[vertex][i]] == false)
      dfs(vertex, adj[vertex][i]);
    else {
      if (adj[vertex][i] != parent) flag = 1;
    }
  }
}
void solve() {
  cin >> n >> m;
  long long int i, x, y;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  int cnt = 0;
  int connected_comp = 0;
  for (i = 1; i <= n; i++) {
    flag = 0;
    if (visited[i] == false) {
      dfs(0, i);
      connected_comp++;
    }
    if (flag) cnt++;
  }
  cout << connected_comp - cnt << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
