#include <bits/stdc++.h>
using namespace std;
std::vector<long long> v[100009];
long long vis[100009], c = 0;
void dfs(long long x) {
  c++;
  vis[x] = 1;
  for (auto i : v[x])
    if (!vis[i]) dfs(i);
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  long long i, n, m, s = 0;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    long long a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (i = 1; i <= n; i++) {
    if (!vis[i]) {
      c = 0;
      dfs(i);
      s += (c - 1);
    }
  }
  cout << m - s;
}
