#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, e, i, j, k, l, m, n, q, r, u, v, w, x, y, z, mn, mx, dx,
    dy;
vector<long long> p(100005, -1);
long long findset(long long x) {
  if (p[x] == -1) return x;
  return p[x] = findset(p[x]);
}
void unionset(long long x, long long y) {
  x = findset(x);
  y = findset(y);
  if (x != y) p[y] = x;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t = 1;
  while (t--) {
    cin >> n >> k;
    long long ans = 0;
    while (k--) {
      cin >> a >> b;
      if (findset(a) == findset(b)) {
        ans++;
        continue;
      }
      unionset(a, b);
    }
    cout << ans;
    cout << "\n";
  }
  return 0;
}
