#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
const long long inf = 1e18;
vector<int> g[maxn];
bool visit[maxn];
int cnt = 0;
void dfs(int u) {
  if (visit[u] == true) return;
  cnt++;
  visit[u] = true;
  for (auto v : g[u]) dfs(v);
}
int main() {
  int n, m;
  cin >> n >> m;
  memset(visit, false, sizeof visit);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (visit[i] == false) {
      cnt = 0;
      dfs(i);
      ans += (cnt - 1);
    }
  }
  cout << (m - ans) << endl;
  return 0;
}
