#include <bits/stdc++.h>
using namespace std;
void process(queue<long long int> &q, vector<vector<long long int> > &v,
             long long int idx, vector<long long int> &taken,
             vector<long long int> &mark) {
  for (long long int i = 0; i < v[idx].size(); i++) {
    if (!taken[v[idx][i]]) {
      taken[v[idx][i]] = 1;
      q.push(v[idx][i]);
    }
  }
  return;
}
void solve(queue<long long int> &q, vector<vector<long long int> > &v,
           vector<pair<long long int, long long int> > &c,
           vector<long long int> &taken, vector<long long int> &mark,
           long long int k, long long int &ans) {
  while (!q.empty()) {
    long long int idx = q.front();
    q.pop();
    bool cnd = true;
    long long int f = c[idx].first;
    if (!mark[f]) {
      mark[f] = 1;
      process(q, v, f, taken, mark);
      cnd = false;
      ans++;
    }
    f = c[idx].second;
    if (!mark[f]) {
      mark[f] = 1;
      process(q, v, f, taken, mark);
      if (cnd) {
        ans++;
      }
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int k, n;
  cin >> k >> n;
  vector<vector<long long int> > v(k + 1);
  vector<pair<long long int, long long int> > c(n);
  vector<long long int> mark(k + 1), taken(n + 1);
  for (long long int i = 0; i < n; i++) {
    cin >> c[i].first >> c[i].second;
    if (c[i].first > c[i].second) {
      swap(c[i].first, c[i].second);
    }
    v[c[i].first].push_back(i);
    v[c[i].second].push_back(i);
  }
  long long int ans = 0;
  for (long long int i = 1; i <= k; i++) {
    if (mark[i]) {
      continue;
    }
    queue<long long int> q;
    for (long long int j = 0; j < v[i].size(); j++) {
      if (!taken[v[i][j]]) {
        q.push(v[i][j]);
        taken[v[i][j]] = 1;
      }
    }
    if (q.size() > 0) {
      solve(q, v, c, taken, mark, k, ans);
    }
  }
  cout << (n - ans);
  return 0;
}
