#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const long long mod = 1e9 + 9;
const int inf = 0x3f3f3f3f;
long long co[maxn];
int ru[maxn];
string str;
long long n, m, k, t, need;
bool vis[maxn];
int ans = 0;
vector<int> ff[maxn];
int bfs(int st) {
  int cnt = 0;
  queue<int> q;
  while (!q.empty()) q.pop();
  q.push(st);
  vis[st] = 1;
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (auto i : ff[now]) {
      if (vis[i]) continue;
      cnt++;
      vis[i] = 1;
      q.push(i);
    }
  }
  return cnt;
}
void dfs(int now) {
  need--;
  vis[now] = 1;
  for (auto i : ff[now]) {
    if (vis[i]) continue;
    ru[i]--;
    if (ru[i] == 1 && !vis[i]) {
      dfs(i);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  need = k;
  int a, b;
  for (int i = 1; i <= k; i++) {
    cin >> a >> b;
    ff[a].emplace_back(b);
    ff[b].emplace_back(a);
    ru[a]++;
    ru[b]++;
  }
  queue<int> q;
  while (!q.empty()) q.pop();
  for (int i = 1; i <= n; i++) {
    if (ru[i] == 1 && !vis[i]) {
      dfs(i);
    }
  }
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    if (ru[i] > 0 && vis[i] == 0) {
      sum += bfs(i);
    }
  }
  cout << need - sum;
}
