#include <bits/stdc++.h>
using namespace std;
double PI = acos(-1.0);
long long mod = 1e9 + 7;
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  return GCD(b, a % b);
}
long long prod(long long a, long long b) {
  long long res = 0;
  a %= mod;
  while (b) {
    if (b & 1ll) res = (res + a) % mod;
    a = (2ll * a) % mod;
    b >>= 1ll;
  }
  return res;
}
long long power(long long a, long long b) {
  long long res = 1ll;
  while (b > 0) {
    if (b % 2ll) res = (res * a) % mod;
    a = (a * a) % mod;
    b /= 2ll;
  }
  return res;
}
long long c = 0, n, k;
vector<vector<long long>> g;
vector<bool> vis;
void dfs(long long x, long long y) {
  queue<long long> q;
  q.push(x);
  q.push(y);
  vis[x] = vis[y] = true;
  c++;
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    for (auto v : g[u]) {
      if (!vis[v]) {
        c++;
        vis[v] = true;
        q.push(v);
      }
    }
  }
}
void solve() {
  cin >> n >> k;
  g = vector<vector<long long>>(n + 1);
  vis = vector<bool>(n + 1, false);
  queue<long long> q;
  vector<pair<long long, long long>> a;
  for (long long i = 0; i < k; i++) {
    long long x, y;
    cin >> x >> y;
    a.push_back({x, y});
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (long long i = 0; i < k; i++) {
    if (!vis[a[i].first] and !vis[a[i].second]) {
      dfs(a[i].first, a[i].second);
    }
  }
  cout << (k - c) << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
}
