#include <bits/stdc++.h>
using namespace std;
long long n, k, m;
vector<long long> parent(1000005), siz(1000005);
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res % 1000000007) * (a % 1000000007);
    a = (a % 1000000007) * (a % 1000000007);
    b >>= 1;
  }
  return res % 1000000007;
}
long long fact[1000007] = {0};
long long expo(long long x, long long y) {
  long long res = 1;
  x = x % 1000000007;
  while (y > 0) {
    if (y & 1) res = (1ll * res * x) % 1000000007;
    y = y >> 1;
    x = (1ll * x * x) % 1000000007;
  }
  return res;
}
void facto() {
  fact[0] = 1;
  fact[1] = 1;
  for (long long i = 2; i < 100007; i++)
    fact[i] = (fact[i - 1] * i) % 1000000007;
}
long long npr(long long n, long long r) {
  facto();
  long long res = 1;
  res = fact[n];
  res = (res * (expo(fact[n - r], 1000000007 - 2))) % 1000000007;
  return res;
};
long long find_dsu(long long m) {
  while (m != parent[m]) {
    parent[m] = parent[parent[m]];
    m = parent[m];
  }
  return m;
}
long long get_size(long long m) { return siz[find_dsu(m)]; }
void dsu_union(long long x, long long y) {
  x = find_dsu(x);
  y = find_dsu(y);
  if (x == y) {
    return;
  }
  if (siz[x] > siz[y]) swap(x, y);
  siz[y] += siz[x];
  siz[x] = 0;
  parent[x] = parent[y];
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  long long a[n + 1];
  for (long long i = 1; i <= n; i++) {
    parent[i] = i;
    siz[i] = 1;
    a[i] = 0;
  }
  long long u, w;
  for (long long i = 0; i < m; i++) {
    cin >> u >> w;
    dsu_union(u, w);
  }
  for (long long i = 1; i <= n; i++) {
    a[find_dsu(i)]++;
  }
  long long e = 0;
  for (long long i = 1; i <= n; i++) {
    if (parent[i] == i) {
      e += a[find_dsu(i)] - 1;
    }
  }
  cout << max((long long)0, m - e) << "\n";
}
