#include <bits/stdc++.h>
using namespace std;
const int MAXn = 3e5 + 5;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
vector<int> adj[MAXn];
bool visited[MAXn];
void dfs(int node) {
  visited[node] = true;
  for (auto x : adj[node]) {
    if (!visited[x]) dfs(x);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  set<pair<int, int> > s;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    s.insert({a, b});
  }
  for (auto x : s) {
    adj[x.first].push_back(x.second);
    adj[x.second].push_back(x.first);
  }
  int count = 0;
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      dfs(i);
      count++;
    }
  }
  int ans = m - (n - count);
  cout << ans;
}
