#include <bits/stdc++.h>
using namespace std;
struct pk {
  int x, y;
  pk(int _x, int _y) {
    x = min(_x, _y);
    y = max(_x, _y);
  }
  bool operator<(const pk& other) const {
    if (x != other.x) return x < other.x;
    return y < other.y;
  }
};
void dfs(vector<vector<int>>& nodes, int cur, int& num, set<int>& candy,
         vector<bool>& seen, vector<pk>& kp, vector<bool>& been) {
  seen[cur] = true;
  num++;
  int x = kp[cur].x, y = kp[cur].y;
  candy.insert(x);
  candy.insert(y);
  if (!been[x]) {
    been[x] = true;
    for (int child : nodes[kp[cur].x]) {
      if (!seen[child]) {
        dfs(nodes, child, num, candy, seen, kp, been);
      }
    }
  }
  if (!been[y]) {
    been[y] = true;
    for (int child : nodes[kp[cur].y]) {
      if (!seen[child]) {
        dfs(nodes, child, num, candy, seen, kp, been);
      }
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  set<pk> ppk;
  for (int i = 0; i < k; ++i) {
    int x, y;
    cin >> x >> y;
    pk p(x, y);
    ppk.insert(p);
  }
  vector<pk> kp(ppk.begin(), ppk.end());
  int ans = k - kp.size();
  k = kp.size();
  ppk.clear();
  vector<vector<int>> nodes(n + 1);
  for (int i = 0; i < k; ++i) {
    nodes[kp[i].x].push_back(i);
    nodes[kp[i].y].push_back(i);
  }
  vector<bool> seen(k, false);
  vector<bool> been(n + 1, false);
  for (int i = 0; i < k; ++i) {
    if (!seen[i]) {
      int num = 0;
      set<int> candy;
      dfs(nodes, i, num, candy, seen, kp, been);
      int sz = candy.size();
      ans += (num - sz + 1);
    }
  }
  cout << ans << endl;
  return 0;
}
