#include <bits/stdc++.h>
using namespace std;
void DFS(vector<int> graph[], vector<int> &a, vector<bool> &vis, int u) {
  vis[u] = true;
  for (int i = 0; i < graph[u].size(); i++) {
    if (vis[graph[u][i]]) continue;
    DFS(graph, a, vis, graph[u][i]);
    a[u] += a[graph[u][i]];
  }
}
int main() {
  long long int n, k;
  int x, y;
  cin >> n >> k;
  vector<int> graph[n];
  vector<int> a(n, 1);
  for (int i = 0; i < k; i++) {
    cin >> x >> y;
    graph[x - 1].push_back(y - 1);
    graph[y - 1].push_back(x - 1);
  }
  int cnt = 0;
  vector<bool> vis(n, false);
  for (int i = 0; i < n; i++)
    if (!vis[i]) {
      DFS(graph, a, vis, i);
      cnt += a[i] - 1;
    }
  cout << k - cnt << endl;
  return 0;
}
