#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
bitset<100005> vis;
int nodes = 0, edges = 0;
void dfs(int v) {
  nodes++;
  vis[v] = true;
  for (auto nv : adj[v]) {
    if (!vis[nv]) dfs(nv);
    edges++;
  }
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int x[k], y[k];
  for (int i = 0; i < k; i++) {
    scanf("%d%d", &x[i], &y[i]);
    adj[--x[i]].push_back(--y[i]);
    adj[y[i]].push_back(x[i]);
  }
  int sad = 0;
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      nodes = 0;
      edges = 0;
      dfs(i);
      edges >>= 1;
      sad += edges - nodes + 1;
    }
  }
  printf("%d\n", sad);
}
