#include <bits/stdc++.h>
using namespace std;
std::vector<int> v[100005];
int vis[100005], cnt;
void dfs(int n) {
  if (vis[n]) return;
  vis[n] = 1;
  for (auto t : v[n]) dfs(t);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int k, n;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y), v[y].push_back(x);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    dfs(i);
    ans++;
  }
  cout << max(0, k - n + ans);
  return 0;
}
