#include <bits/stdc++.h>
using namespace std;
vector<int> a[1000005];
int n, m, vis[1000005], bs, ds;
void dfs(int u) {
  vis[u] = 1;
  ds++;
  for (int i = 0; i < a[u].size(); i++) {
    bs++;
    if (!vis[a[u][i]]) dfs(a[u][i]);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    a[u].push_back(v);
    a[v].push_back(u);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      bs = 0;
      ds = 0;
      dfs(i);
      bs /= 2;
      ans += max(0, bs - ds + 1);
    }
  }
  printf("%d", ans);
  return 0;
}
