#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
long long int n, m, c = 0, cc = 0, s = 0;
long long int vis[100001];
vector<long long int> ar[100001];
void dfs(long long int i) {
  c++;
  vis[i] = 1;
  for (long long int ch : ar[i]) {
    if (vis[ch] == 0) dfs(ch);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    long long int x, y;
    cin >> x >> y;
    ar[x].push_back(y);
    ar[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    c = 0;
    if (vis[i] == 0 && ar[i].size() >= 1) {
      cc++;
      dfs(i);
      s += c;
    }
  }
  printf("%lld\n", m - s + cc);
}
