#include <bits/stdc++.h>
using namespace std;
vector<long long> ad[200009];
long long vis[200009];
long long cnt, ans;
void dfs(int u) {
  vis[u] = 1;
  cnt++;
  for (auto x : ad[u]) {
    if (!vis[x]) dfs(x);
  }
}
int main() {
  long long i, j, k, l, m, n, u, v;
  cin >> n >> k;
  for (i = 0; i < k; i++) {
    cin >> u >> v;
    ad[u].push_back(v);
    ad[v].push_back(u);
  }
  for (i = 1; i <= n; i++) {
    if (ad[i].size() == 0) continue;
    if (!vis[i]) {
      cnt = 0;
      dfs(i);
      cnt--;
      ans += cnt;
    }
  }
  cout << k - ans << '\n';
}
