#include <bits/stdc++.h>
using namespace std;
const long long MOD = 10007;
const long long MAX = 1LL << 60;
vector<vector<int>> g;
vector<bool> visit;
int dfs(int n) {
  visit[n] = true;
  int cnt = 1;
  for (int i : g[n]) {
    if (visit[i]) continue;
    cnt += dfs(i);
  }
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);
  int n, k;
  cin >> n >> k;
  g.resize(n + 1);
  visit.resize(n + 1);
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int happy = 0;
  for (int i = 1; i <= n; i++) {
    if (!visit[i]) {
      happy += dfs(i) - 1;
    }
  }
  cout << k - happy << "\n";
  return 0;
}
