#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) {
  cnt = 0;
  queue<int> q;
  q.push(u);
  visit[u] = true;
  cnt++;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto v : g[u])
      if (visit[v] == false) {
        q.push(v);
        visit[v] = true;
        cnt++;
      }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  vector<int> st;
  int u, v;
  memset(visit, false, sizeof visit);
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    st.push_back(u);
    st.push_back(v);
  }
  int ans = 0;
  for (auto v : st) {
    if (visit[v] == false) {
      dfs(v);
      ans += (cnt - 1);
      cnt = 0;
    }
  }
  cout << (m - ans) << endl;
  return 0;
}
