#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
const ll MOD = 1e9 + 7, N = 1e5 + 10;
vector<ll> g[N], vis(N, 0);
ll ans = 0;
void dfs(ll u) {
  vis[u] = 1;
  for (auto &v : g[u]) {
    if (!vis[v]) {
      ans++;
      dfs(v);
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll n, k;
  cin >> n >> k;
  vector<pii> a(k);
  for (ll i = 0; i < k; i++) {
    cin >> a[i].first >> a[i].second;
    g[a[i].first].push_back(a[i].second);
    g[a[i].second].push_back(a[i].first);
  }
  for (ll i = 1; i < n + 1; i++) {
    if (!vis[i]) {
      dfs(i);
    }
  }
  ans = k - ans;
  cout << ans << '\n';
  return 0;
}
