#include <bits/stdc++.h>
using namespace std;
long double pie = 3.141592653589793238462643383279;
long long mod = 1e9 + 7;
long long dx[] = {-1, 1, 0, 0};
long long dy[] = {0, 0, 1, -1};
vector<long long> adj[1000005];
bool vis[1000005];
bool vis2[1000005];
long long ans[1000005];
long long dfs(long long s) {
  vis[s] = 1;
  long long r = 1;
  for (auto it : adj[s]) {
    if (!vis[it]) {
      r += dfs(it);
    }
  }
  return r;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long cp = m;
  while (m--) {
    long long a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  long long sat = 0;
  for (long long i = 1; i <= n; ++i) {
    if (!vis[i]) {
      sat += dfs(i);
      sat--;
    }
  }
  cout << cp - sat;
  return 0;
}
