#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn], b[maxn], vis[maxn];
vector<int> v[maxn];
int ans;
void dfs(int x) {
  for (int i = 0; i < v[x].size(); i++) {
    if (vis[v[x][i]] == 1)
      continue;
    else {
      vis[v[x][i]] = 1;
      ans--;
      dfs(v[x][i]);
    }
  }
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d%d", &a[i], &b[i]);
    v[a[i]].push_back(b[i]);
    v[b[i]].push_back(a[i]);
  }
  ans = k;
  for (int i = 1; i <= k; i++) {
    if (!vis[a[i]]) {
      vis[a[i]] = 1;
      vis[b[i]] = 1;
      ans--;
      dfs(a[i]);
      dfs(b[i]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
