#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 1e5 + 5;
vector<long long> g[N];
bool vis[N];
long long indeg[N];
long long cnt;
void dfs(long long u) {
  vis[u] = true;
  for (long long v : g[u]) {
    if (!vis[v]) {
      cnt++;
      dfs(v);
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long x, y;
  for (long long i = 0; i < k; i++) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (long long i = 1; i <= n; i++) {
    vis[i] = false;
  }
  cnt = 0;
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i);
    }
  }
  cout << k - cnt;
  return 0;
}
