#include <bits/stdc++.h>
using namespace std;
int fa[100010];
int Find(int x) { return fa[x] == x ? x : fa[x] = Find(fa[x]); }
int main() {
  int n, k, x, y;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) fa[i] = i;
  int ans = 0;
  for (int i = 1; i <= k; i++) {
    scanf("%d%d", &x, &y);
    int g1 = Find(x), g2 = Find(y);
    if (g1 != g2) fa[g1] = g2, ans++;
  }
  printf("%d\n", k - ans);
  return 0;
}
