#include <bits/stdc++.h>
using namespace std;
set<int> v[100009];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int mi = INT_MAX, ma = INT_MIN, gcd, i, j, k, w, d, x, y, z, x1, y1, p, q, r,
      n, m, root, t, sum, ans1, size;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    v[x].insert(y);
    v[y].insert(x);
  }
  int vis[100009], ans = 0;
  memset(vis, 0, sizeof(vis));
  for (i = 1; i <= n; i++)
    if (vis[i] == 0) {
      queue<int> qu;
      qu.push(i);
      vis[i] = 1;
      sum = 0;
      while (qu.size()) {
        j = qu.front();
        qu.pop();
        for (auto it : v[j])
          if (vis[it] == 0) {
            qu.push(it);
            vis[it] = 1;
            sum++;
          }
      }
      ans += sum;
    }
  cout << m - ans;
  return 0;
}
