#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int k, n, t;
pair<int, int> a[100001];
vector<int> graph[100001];
bool used[100001];
void dfs(int u) {
  used[u] = true;
  for (auto v : graph[u]) {
    if (!used[v]) {
      dfs(v);
    }
  }
}
int main() {
  t = 1;
  while (t--) {
    cin >> n >> k;
    for (int i = 1; i <= k; ++i) {
      cin >> a[i].first >> a[i].second;
      graph[a[i].first].push_back(a[i].second);
      graph[a[i].second].push_back(a[i].first);
    }
    int c = 0;
    for (int i = 1; i <= n; ++i) {
      if (!used[i]) {
        dfs(i), ++c;
      }
    }
    cout << k - (n - c) << endl;
  }
  return 0;
}
