#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 7;
bool used[N];
vector<long long> g[N];
void dfs(long long u) {
  used[u] = 1;
  for (long long v : g[u])
    if (!used[v]) dfs(v);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; ++i) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  long long c = 0;
  for (long long i = 1; i <= n; ++i) {
    if (!used[i]) {
      ++c;
      dfs(i);
    }
  }
  cout << m - (n - c) << '\n';
}
