#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
vector<int> g[N];
int used[N];
int dfs(int v) {
  int size = 1;
  used[v] = 1;
  for (int to : g[v]) {
    if (!used[to]) size += dfs(to);
  }
  return size;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; (i) < (k); ++i) {
    int v, u;
    cin >> v >> u;
    v--, u--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  int maxEdges = 0;
  for (int i = 0; (i) < (n); ++i) {
    if (!used[i]) {
      int size = dfs(i);
      maxEdges += size - 1;
    }
  }
  cout << k - maxEdges << '\n';
  return 0;
}
