#include <bits/stdc++.h>
using namespace std;
int sad = 0;
int* visited;
vector<int>* adj;
void dfs(int curr, int prev) {
  visited[curr] = 1;
  for (auto& e : adj[curr]) {
    if (e == prev) continue;
    if (visited[e])
      sad++;
    else
      dfs(e, curr);
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  visited = new int[n];
  memset(visited, 0, n * sizeof(int));
  adj = new vector<int>[n];
  unordered_set<string> chk;
  int dups = 0;
  for (int i = 0; i < k; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    int tmp = min(a, b);
    int tmp2 = max(a, b);
    string key = to_string(tmp) + to_string(tmp2);
    if (chk.count(key)) {
      dups++;
      continue;
    }
    chk.insert(key);
    adj[a - 1].push_back(b - 1);
    adj[b - 1].push_back(a - 1);
  }
  for (int i = 0; i < n; i++) {
    if (visited[i]) continue;
    dfs(i, -1337);
  }
  cout << sad / 2 + dups;
}
