#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int f[N], n, m, b[N], st[N];
int find(int x) {
  if (x != f[x]) f[x] = find(f[x]);
  return f[x];
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) f[i] = i;
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a = find(a), b = find(b);
    if (a != b) f[a] = b;
  }
  int len = 0;
  for (int i = 1; i <= n; i++) {
    if (find(i) == i) {
      b[i] = len++;
    }
  }
  int res = 0;
  for (int i = 1; i <= n; i++) {
    st[b[find(i)]]++;
  }
  for (int i = 0; i < len; i++) {
    res += st[i] - 1;
  }
  cout << m - res << endl;
  return 0;
}
