#include <bits/stdc++.h>
using namespace std;
int dfs(vector<vector<int> > &ady, vector<bool> &visited, int n) {
  int tree = 0;
  visited[n] = true;
  for (auto &x : ady[n]) {
    if (!visited[x]) tree += 1 + dfs(ady, visited, x);
  }
  return tree;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t, n, m, a, b;
  cin >> m >> n;
  vector<bool> visited(m + 1, false);
  vector<vector<int> > ady(m + 1);
  for (int i = 0; i < n; ++i) {
    cin >> a >> b;
    ady[a].push_back(b);
    ady[b].push_back(a);
  }
  int ans = n;
  for (int i = 1; i <= m; ++i) {
    if (!visited[i]) ans -= dfs(ady, visited, i);
  }
  cout << ans << "\n";
  return 0;
}
