#include <bits/stdc++.h>
using namespace std;
int fa[100010];
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
bool merge(int x, int y) {
  int f1 = find(x), f2 = find(y);
  if (f1 == f2) return false;
  fa[f2] = f1;
  return true;
}
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int ans = 0;
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= k; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    ans += merge(u, v);
  }
  printf("%d\n", k - ans);
  return 0;
}
