%:pragma GCC optimize("Ofast")
  %:pragma GCC optimize("inline")
#include <bits/stdc++.h>
#define int long long
#define rint register int
using namespace std;

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
#define pb push_back
const int N = 3e5 + 233;
int n, m, col[N], du[N], inq[N];
vector <int> g[N];
main(void) {
  read(n); read(m);
  assert(n - 1 == m);
  for (int i = 2; i <= n; i ++) {
    int x, y; read(x); read(y);
    g[x].pb(y); g[y].pb(x);
    ++ du[x]; ++ du[y];
  }
  queue <int> q;
  for (int i = 1; i <= n; i ++)
    if (du[i] == 1) {
      q.push(i);
    }
  int ans = 0;
  while (!q.empty()) {
    int u = q.front(); q.pop(); inq[u] = true;
    // cout << u << "\n";
    for (auto &v : g[u]) if (!inq[v]) {
      col[v] ^= 1;
      -- du[v];
      ++ ans;
      if (du[v] == 1) {
        if (!col[v]) q.push(v);
      }
    }
  }
  cout << ans << "\n";
}
