#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 100;
const int md = 1000000007;
priority_queue<int, vector<int>, greater<int> > pq;
bool compare(pair<int, int> &a, pair<int, int> &b) { return a.first < b.first; }
int n, k, visited[mx] = {}, sudah[mx] = {};
pair<int, int> arr[mx];
vector<pair<int, int> > temp;
vector<vector<int> > path(mx);
int ans = 0;
void bfs(pair<int, int> x) {
  queue<int> que;
  que.push(x.first);
  que.push(x.second);
  while (que.empty() == false) {
    int z = que.front();
    que.pop();
    sudah[z] = true;
    for (int i = 0; i < path[z].size(); i += 1) {
      int a = path[z][i];
      if (visited[a] == false) {
        visited[a] = true;
        ans += sudah[arr[a].first] && sudah[arr[a].second];
        if (sudah[arr[a].first] == false) que.push(arr[a].first);
        if (sudah[arr[a].second] == false) que.push(arr[a].second);
        sudah[arr[a].first] = sudah[arr[a].second] = true;
      }
    }
  }
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < k; i += 1) {
    int x, y;
    scanf("%d %d", &x, &y);
    arr[i] = make_pair(x, y);
    path[x].push_back(i);
    path[y].push_back(i);
  }
  for (int i = 0; i < k; i += 1) {
    if (visited[i] == false) {
      bfs(arr[i]);
    }
  }
  printf("%d\n", ans);
}
