#include <bits/stdc++.h>
using namespace std;
int cnt = 0;
int p[100005];
int find(int x) {
  if (x == p[x])
    return x;
  else
    return p[x] = find(p[x]);
}
void uni(int x, int y) {
  int p_x = find(x);
  int p_y = find(y);
  if (p_x == p_y)
    cnt++;
  else {
    p[p_x] = p_y;
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i <= n; i++) p[i] = i;
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    uni(x, y);
  }
  cout << cnt << endl;
}
