#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = 2 * acos(0.0);
const int INF = 1e9;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vii = vector<vi>;
using vll = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  vb vis(n + 1, 0);
  vector<vector<int> > v(n + 1);
  vpii s(k);
  for (int i = (0); i < (int)(k); i++) {
    pii p;
    cin >> p.first >> p.second;
    s.push_back(p);
    v[p.first].push_back(p.second);
    v[p.second].push_back(p.first);
  }
  int eat = 0;
  for (pii p : s) {
    queue<int> q;
    if (vis[p.first] && vis[p.second]) continue;
    q.push(vis[p.first] ? p.second : p.first);
    vis[q.front()] = 1;
    while (!q.empty()) {
      int e = q.front();
      q.pop();
      for (int f : v[e]) {
        if (vis[f]) continue;
        vis[f] = 1;
        eat++;
        q.push(f);
      }
    }
  }
  cout << k - eat << endl;
  return 0;
}
