#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int n, k;
int a[100010][2];
vector<int> p2[100010];
int vis[100010];
int stk[100010];
int st = 0;
int stki = 0;
int main() {
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    scanf("%d %d", a[i], a[i] + 1);
    p2[a[i][0]].push_back(a[i][1]);
    p2[a[i][1]].push_back(a[i][0]);
  }
  int happy = 0;
  for (int i = 0; i < k; i++) {
    if (vis[a[i][0]] == 0 || vis[a[i][1]] == 0) {
      happy++;
      if (vis[a[i][0]] == 0) {
        stk[stki++] = a[i][0];
        vis[a[i][0]] = 1;
      }
      if (vis[a[i][1]] == 0) {
        stk[stki++] = a[i][1];
        vis[a[i][1]] = 1;
      }
    }
    while (st < stki) {
      int c = stk[st];
      for (auto item : p2[c]) {
        if (vis[item]) continue;
        vis[item] = 1;
        happy++;
        stk[stki++] = item;
      }
      st++;
    }
  }
  printf("%d\n", k - happy);
  return 0;
}
