#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n, k;
long long a[N];
void ini() {
  for (long long i = 1; i < n + 1; i++) {
    a[i] = i;
  }
}
long long root(long long x) {
  while (x != a[x]) {
    a[x] = a[a[x]];
    x = a[x];
  }
  return x;
}
void uni(long long x, long long y) {
  x = root(x), y = root(y);
  if (x != y) a[x] = a[y];
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n >> k;
  long long ans = 0;
  ini();
  for (long long i = 0; i < k; i++) {
    long long x, y;
    cin >> x >> y;
    if (root(x) != root(y)) ans++;
    uni(x, y);
  }
  cout << k - ans;
}
