#include <bits/stdc++.h>
using namespace std;
using vi = vector<long long>;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
unsigned long long power(long long x, unsigned long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  if (a.first > b.first)
    return 0;
  else if (b.first > a.first)
    return 1;
  else
    return (b.second > a.second);
}
const long long maxn = 1e5 + 5;
bool vis[maxn];
vector<long long> v[maxn];
void dfs(long long x, long long &cnt) {
  vis[x] = true;
  for (auto it : v[x]) {
    if (!vis[it]) {
      cnt += 1;
      dfs(it, cnt);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long x;
    cin >> x;
    ;
    long long y;
    cin >> y;
    ;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) {
      long long cnt = 1;
      dfs(i, cnt);
      if (cnt == 1)
        continue;
      else {
        ans += cnt - 1;
      }
    }
  }
  cout << m - ans << "\n";
}
