#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
long long lgput(long long a, long long b, long long MOD) {
  long long ret = 1LL;
  while (b) {
    if (b & 1LL) ret = (ret * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1LL;
  }
  return (ret % MOD);
}
long long inv_mod(long long x, long long MOD) { return lgput(x, MOD - 2, MOD); }
long long GCD(long long a, long long b) {
  long long c;
  while (b) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
long long LCM(long long a, long long b) { return (a * b) / GCD(a, b); }
long long big_rand() { return 1LL * rand() * RAND_MAX + rand(); }
long long xtime() { return clock() * 1000LL / CLOCKS_PER_SEC; }
bool exist(double nr, double eps) { return (nr < -eps) || (nr > eps); }
long long modd(long long nr, long long MOD) { return ((nr % MOD) + MOD) % MOD; }
void start() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << setprecision(10) << fixed;
  srand(time(nullptr));
}
const mt19937 rng(time(nullptr));
const double PI = acos(-1);
const double eps = 1e-6;
const long long inf = 1e9;
const long long MOD = 1e9 + 7;
const long long MAXN = 1e5 + 10;
struct nod {
  int a, b;
};
int n, m;
int used[MAXN];
vector<int> gr[MAXN];
int cont = 0;
void read() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    gr[a].push_back(b);
    gr[b].push_back(a);
  }
}
void dfs(int nod) {
  cont++;
  used[nod] = 1;
  for (auto& x : gr[nod]) {
    if (!used[x]) {
      dfs(x);
    }
  }
}
void solve() {
  read();
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      cont = 0;
      dfs(i);
      ans += cont - 1;
    }
  }
  cout << m - ans;
}
int main() {
  start();
  solve();
  return 0;
}
