#include <bits/stdc++.h>
using namespace std;
const long long m = 1000000000 + 7;
const long long MOD1 = 998244353;
string itos(long long s) {
  string str = to_string(s);
  return str;
}
long long power(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
bool ispalindrome(long long len, string str) {
  for (int i = 0; i < len / 2; i++) {
    if (str[i] != str[len - 1 - i]) {
      return false;
    }
  }
  return true;
}
vector<long long> ad[200005];
vector<long long> parent(200005, 0), siz(200005, 0);
void make_set(long long v, vector<long long> &parent, vector<long long> &siz) {
  parent[v] = v;
  siz[v] = 1;
}
long long find_set(long long x, vector<long long> &parent) {
  if (x == parent[x])
    return x;
  else {
    return parent[x] = find_set(parent[x], parent);
  }
}
void union_set(long long a, long long b, vector<long long> &siz,
               vector<long long> &parent) {
  a = find_set(a, parent);
  b = find_set(b, parent);
  if (a != b) {
    if (siz[a] < siz[b]) swap(a, b);
    parent[b] = a;
    siz[a] += siz[b];
    siz[b] = 0;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  for (long long i = (long long)0; i < (long long)n + 1; i++)
    make_set(i, parent, siz);
  long long cnt = 0;
  for (long long i = (long long)0; i < (long long)m; i++) {
    long long u, v;
    cin >> u >> v;
    if (find_set(u, parent) == find_set(v, parent))
      cnt++;
    else
      union_set(u, v, siz, parent);
  }
  cout << cnt;
}
