#include <bits/stdc++.h>
using namespace std;
const int OO = 1e8 + 9, N = 1e5 + 9;
const long long mod = 1e9 + 7;
vector<int> adj[N];
int vis[N], vis2[N], taken[N];
int ans = 0;
pair<int, int> arr[N];
void solve(int i) {
  if (vis[i]) return;
  vis[i] = 1;
  int a = arr[i].first, b = arr[i].second;
  if (taken[a] && taken[b]) ans++;
  taken[a] = taken[b] = 1;
  if (!vis2[a]) {
    vis2[a] = 1;
    for (auto child : adj[a]) solve(child);
  }
  if (!vis2[b]) {
    vis2[b] = 1;
    for (auto child : adj[b]) solve(child);
  }
}
void test() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; i++)
    cin >> arr[i].first >> arr[i].second, adj[arr[i].first].push_back(i),
        adj[arr[i].second].push_back(i);
  for (int i = 0; i < k; i++) solve(i);
  printf("%d\n", ans);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int t = 1;
  for (int cas = 1; cas <= t; cas++) test();
}
