#include <bits/stdc++.h>
using namespace std;
int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }
int fastMin(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; }
const long long int MAXN = 1e5 + 10;
bool visit[MAXN];
long long int parent[MAXN];
long long int rankk[MAXN];
long long int findd(long long int x) {
  while (parent[x] != x) {
    parent[x] = parent[parent[x]];
    x = parent[x];
  }
  return x;
}
void unionn(long long int x, long long int y) {
  x = findd(x), y = findd(y);
  if (x == y) return;
  if (rankk[x] > rankk[y]) {
    rankk[x] += rankk[y];
    parent[y] = x;
  } else {
    rankk[y] += rankk[x];
    parent[x] = y;
  }
}
void solve() {
  long long int n, k;
  cin >> n >> k;
  for (long long int i = (1); i <= (n); ++i) parent[i] = i, rankk[i] = 1;
  for (long long int i = (1); i <= (k); ++i) {
    long long int x, y;
    cin >> x >> y;
    unionn(x, y);
  }
  long long int ans = 0;
  for (long long int i = (1); i <= (n); ++i) {
    long long int x = findd(i);
    if (visit[x]) continue;
    visit[x] = true;
    ans += rankk[x] - 1;
  }
  cout << k - ans << '\n';
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t;
  t = 1;
  for (long long int i = (1); i <= (t); ++i) {
    solve();
  }
}
