#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, k;
int pr[N], sz[N];
int root(int x) { return pr[x] = (pr[x] == x ? x : root(pr[x])); }
void merge(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y) return;
  if (rand() & 1) {
    pr[x] = y;
    sz[y] += sz[x];
  } else {
    pr[y] = x;
    sz[x] += sz[y];
  }
}
int main() {
  for (int i = 0; i < N; i++) {
    pr[i] = i;
    sz[i] = 1;
  }
  scanf("%d %d", &n, &k);
  for (int i = 0; i < k; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    merge(u, v);
  }
  int sat = 0;
  for (int i = 0; i < n; i++)
    if (root(i) == i) sat += sz[i] - 1;
  printf("%d\n", k - sat);
  return 0;
}
