#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
const int N = 1010100;
int usd[N], n, head[N], tt, ans, k;
struct pr {
  int next, to;
} a[N];
void add(int u, int v) {
  a[++tt] = (pr){head[u], v};
  head[u] = tt;
}
void dfs(int x) {
  usd[x] = 1;
  for (int i = head[x]; i; i = a[i].next) {
    int y = a[i].to;
    if (!usd[y]) {
      ans++;
      dfs(y);
    }
  }
}
int main() {
  n = read();
  k = read();
  for (int i = 1; i <= k; i++) {
    int x = read(), y = read();
    add(x, y);
    add(y, x);
  }
  usd[0] = 1;
  for (int i = 1; i <= n; i++) {
    if (!usd[i]) dfs(i);
  }
  cout << k - ans << '\n';
}
