#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long Hashimoto = 0;
  bool Kanna = 1;
  char I_Love = getchar();
  while (I_Love < '0' || I_Love > '9') {
    if (I_Love == '-') Kanna = 0;
    I_Love = getchar();
  }
  while (I_Love >= '0' && I_Love <= '9') {
    Hashimoto = Hashimoto * 10 + I_Love - '0';
    I_Love = getchar();
  }
  return (Kanna ? Hashimoto : -Hashimoto);
}
template <typename T1, typename T2>
inline void Umax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <typename T1, typename T2>
inline void Umin(T1 &a, T2 b) {
  if (a > b) a = b;
}
int n, m;
int g[111111][2];
vector<int> h[111111];
int cv, cy;
bool v[111111];
bool y[111111];
void cow(int x);
void sna(int x);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int ans = 0;
  n = read();
  m = read();
  for (int i = 0; i < (m); ++i) {
    g[i][0] = read(), g[i][1] = read();
    h[g[i][0]].push_back(i);
    h[g[i][1]].push_back(i);
  }
  for (int i = 0; i < (m); ++i)
    if (!v[i]) {
      cv = cy = 0;
      cow(i);
      ans += cv - cy + 1;
    }
  cout << ans << endl;
  ;
  return 0;
}
void cow(int x) {
  cv++;
  v[x] = 1;
  if (!y[g[x][0]]) sna(g[x][0]);
  if (!y[g[x][1]]) sna(g[x][1]);
}
void sna(int x) {
  cy++;
  y[x] = 1;
  for (int i = 0; i < (h[x].size()); ++i) {
    int to = h[x][i];
    if (!v[to]) cow(to);
  }
}
