#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<vector<int> > a(n);
  vector<pair<int, int> > g;
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    g.push_back({x - 1, y - 1});
    a[x - 1].push_back(y - 1);
    a[y - 1].push_back(x - 1);
  }
  int an = 0;
  vector<int> v(n);
  for (int i = 0; i < k; i++) {
    int x = g[i].first, y = g[i].second;
    if (v[x] == 1) continue;
    v[x] = v[y] = 1;
    queue<int> q;
    q.push(x);
    q.push(y);
    an++;
    while (!q.empty()) {
      int t = q.front();
      q.pop();
      for (int j = 0; j < a[t].size(); j++) {
        if (v[a[t][j]] == 0) {
          an++;
          q.push(a[t][j]);
          v[a[t][j]] = 1;
        }
      }
    }
  }
  cout << k - an << endl;
  return 0;
}
