#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int p[N], x[N], y[N];
int n, k;
int findp(int x) {
  if (p[x] == -1) return x;
  return p[x] = findp(p[x]);
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= k; i++) cin >> x[i] >> y[i];
  memset(p, -1, sizeof(p));
  int cnt = 0;
  for (int i = 1; i <= k; i++) {
    int fx = findp(x[i]), fy = findp(y[i]);
    if (fx == fy)
      cnt++;
    else
      p[fx] = fy;
  }
  cout << cnt << endl;
}
