#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > adj(100050);
int n, k;
int vi[100050];
int co = 0;
void dfs(int a) {
  if (vi[a]) return;
  vi[a] = 1;
  co++;
  for (auto j : adj[a]) {
    if (!vi[j]) dfs(j);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    co = 0;
    if (vi[i]) continue;
    dfs(i);
    ans += co - 1;
  }
  int pr = k - ans;
  if (pr < 0) pr = 0;
  cout << pr;
  return 0;
}
