#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:640000000")
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = (int)1e5 + 10;
vector<int> g[maxn];
int r[maxn];
bool dead[maxn];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    g[x].push_back(y);
    g[y].push_back(x);
    r[x]++;
    r[y]++;
  }
  queue<int> q;
  int happy = 0;
  for (int i = 0; i < n; i++)
    if (r[i] == 1) {
      q.push(i);
    }
  for (int i = 0; i < n; i++)
    if (r[i] == 0) {
      dead[i] = true;
    }
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    dead[v] = true;
    bool alive = false;
    for (int i = 0; i < (int)(g[v]).size(); i++) {
      int to = g[v][i];
      if (dead[to]) continue;
      alive = true;
      r[to]--;
      if (r[to] == 1) {
        q.push(to);
      }
    }
    if (alive) {
      happy++;
    }
  }
  for (int i = 0; i < n; i++)
    if (!dead[i]) {
      int cnt = 0;
      q.push(i);
      while (!q.empty()) {
        int v = q.front();
        q.pop();
        cnt++;
        dead[v] = true;
        for (int j = 0; j < (int)(g[v]).size(); j++) {
          int to = g[v][j];
          if (dead[to]) continue;
          dead[to] = true;
          q.push(to);
        }
      }
      happy += cnt - 1;
    }
  cout << k - happy << endl;
  return 0;
}
