#include <bits/stdc++.h>
using namespace std;
int n, m, res;
vector<int> g[100005];
bool used[100005], av[100005];
void dfs(int u) {
  used[u] = true;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (!used[v]) {
      res++;
      dfs(v);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u;
    int v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    av[u] = true;
    av[v] = true;
  }
  for (int u = 1; u <= n; u++)
    if (av[u] && !used[u]) dfs(u);
  cout << m - res;
}
