#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, m;
int pre[maxn];
void init(int n) {
  for (int i = 0; i <= n + 1; i++) pre[i] = i;
}
int finds(int x) {
  if (x == pre[x])
    return x;
  else
    return pre[x] = finds(pre[x]);
}
int main() {
  while (cin >> n >> m) {
    int ans = 0;
    init(n);
    for (int i = 1, a, b; i <= m; i++) {
      cin >> a >> b;
      int fa = finds(a);
      int fb = finds(b);
      if (fa != fb) {
        pre[fa] = fb;
      } else
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
