#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = 0x3f3f3f3f;
const int N = 1e6 + 10;
int f[N];
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
int merge(int x, int y) {
  int t1 = find(x);
  int t2 = find(y);
  if (t1 != t2) {
    f[t2] = t1;
    return 0;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, k;
  cin >> n >> k;
  for (int i = 0; i <= n; i++) f[i] = i;
  int ans = 0;
  for (int i = 1; i <= k; i++) {
    int x, y;
    cin >> x >> y;
    ans += merge(x, y);
  }
  cout << ans << endl;
  return 0;
}
