#include <bits/stdc++.h>
using namespace std;
void FAST() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const long long md = 1000000007;
const long long inf = 1e18L + 5;
const char nl = '\n';
const int N = 100005;
int main() {
  FAST();
  int tt{}, T{};
  tt = 1;
  while (tt--) {
    string str, sa, sb;
    int n{}, m{}, ans{}, k{}, a{}, b{}, c{}, x{}, y{}, f{};
    cin >> n >> k;
    vector<std::pair<int, int> > v(k);
    map<int, int> mm;
    std::vector<int> z(n + 1, 0);
    c = md;
    vector<std::vector<int> > v1(N);
    for (int i = 0; i < k; ++i) {
      cin >> v[i].first >> v[i].second;
      v1[v[i].first].push_back(i);
      v1[v[i].second].push_back(i);
      mm[v[i].first]++;
      mm[v[i].second]++;
      if (max(mm[v[i].first], mm[v[i].second]) < c) {
        c = max(mm[v[i].first], mm[v[i].second]);
        a = i;
      }
    }
    set<int> s;
    for (int i = 0; i < k; ++i) s.insert(i);
    queue<int> q;
    q.push(a);
    s.erase(a);
    while (1) {
      f = 0;
      while (!q.empty()) {
        a = q.front();
        q.pop();
        y = z[v[a].second];
        f = 0;
        if (z[v[a].first] == 0) {
          z[v[a].first] = 1;
          z[v[a].second] = 1;
          for (auto& e : v1[v[a].first]) {
            if (z[v[e].first] + z[v[e].second] < 2) {
              q.push(e);
              if (s.find(e) != s.end()) {
                s.erase(e);
              }
            }
          }
          f = 1;
        }
        z[v[a].second] = y;
        if (z[v[a].second] == 0) {
          z[v[a].second] = 1;
          for (auto& e : v1[v[a].second]) {
            if (z[v[e].first] + z[v[e].second] < 2) {
              q.push(e);
              if (s.find(e) != s.end()) {
                s.erase(e);
              }
            }
          }
          f = 1;
        }
        if (!f) ++ans;
      }
      if (s.size()) {
        q.push(*s.begin());
        s.erase(s.begin());
      } else {
        break;
      }
    }
    cout << ans << nl;
  }
  return 0;
}
