#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, INF = 0x3f3f3f3f, M = 1e9 + 7;
const long long LNF = 0x3f3f3f3f3f3f3f3f;
int n, k, a, b, p[N], ans;
int f(int x) { return p[x] == x ? x : (p[x] = f(p[x])); }
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 1; i <= k; i++) {
    cin >> a >> b;
    int fa = f(a), fb = f(b);
    if (fa == fb)
      ans++;
    else
      p[fa] = fb;
  }
  cout << ans << '\n';
}
