#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class Ty>
Ty randint(Ty a, Ty b) {
  return uniform_int_distribution<Ty>(a, b)(rng);
}
template <class T>
void DBG(T&& x) {
  cerr << x << " ";
}
template <class T, class... Args>
void DBG(T&& x, Args&&... args) {
  DBG(x);
  DBG(args...);
}
template <class num>
inline void rd(num& x) {
  cin >> x;
}
template <class Ty, class... Args>
inline void rd(Ty& x, Args&... args) {
  rd(x);
  rd(args...);
}
template <class num>
inline void print(num&& x) {
  cout << x;
}
template <class Ty, class... Args>
inline void print(Ty&& x, Args&&... args) {
  print(x);
  print(' ');
  print(args...);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  rd(k, n);
  vector<int> f(k);
  vector<pii> v(n);
  vector<vector<int>> who(k);
  for (int i = 0; i < n; i++) {
    int a, b;
    rd(a, b);
    a--, b--;
    v[i] = {a, b};
    who[a].push_back(i);
    who[b].push_back(i);
    f[a]++, f[b]++;
  }
  vector<int> order(n);
  iota(order.begin(), order.end(), 0);
  sort(order.begin(), order.end(), [&](int i, int j) {
    return min(f[v[i].first], f[v[i].second]) <
           min(f[v[j].first], f[v[j].second]);
  });
  int ans = 0;
  vector<int> x(k, 1), used(n), added(n);
  while (order.size()) {
    int u = order.back();
    order.pop_back();
    if (used[u]) continue;
    used[u] = 1;
    auto [a, b] = v[u];
    if (!x[a] && !x[b])
      ans++;
    else {
      bool hasa = x[a];
      bool hasb = x[b];
      x[a] = max(0, x[a] - 1);
      x[b] = max(0, x[b] - 1);
      auto gogo = [&](int candy) {
        for (int i : who[candy])
          if (!used[i] && !added[i]) {
            if (x[v[i].first] + x[v[i].second] == 1) {
              order.push_back(i);
              added[i] = 1;
            }
          }
      };
      if (hasa) gogo(a);
      if (hasb) gogo(b);
    }
  }
  print(ans), print('\n');
}
