#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 1;
vector<vector<long long>> adj;
long long n, k;
bool used[N] = {};
long long solve(long long x) {
  used[x] = true;
  long long rtn = 1;
  for (long long i = 0; i < adj[x].size(); i++) {
    if (!used[adj[x][i]]) rtn += solve(adj[x][i]);
  }
  return rtn;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  adj = vector<vector<long long>>(n + 1);
  for (long long x, y, i = 0; i < k; i++) {
    cin >> x >> y;
    adj[x - 1].push_back(y - 1);
    adj[y - 1].push_back(x - 1);
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++)
    if (!used[i]) ans += solve(i) - 1;
  cout << k - ans << '\n';
  return 0;
}
