#include <bits/stdc++.h>
template <class t>
inline void read(t &s) {
  s = 0;
  register int f = 1;
  register char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
  s *= f;
  return;
}
template <class t, class... A>
inline void read(t &x, A &...a) {
  read(x);
  read(a...);
}
template <class t>
inline void write(t x) {
  if (x < 0) putchar('-'), x = -x;
  int buf[21], top = 0;
  while (x) buf[++top] = x % 10, x /= 10;
  if (!top) buf[++top] = 0;
  while (top) putchar(buf[top--] ^ '0');
  return;
}
inline void setIn(std::string s) {
  freopen(s.c_str(), "r", stdin);
  return;
}
inline void setOut(std::string s) {
  freopen(s.c_str(), "w", stdout);
  return;
}
inline void setIO(std::string s = "") {
  setIn(s + ".in");
  setOut(s + ".out");
  return;
}
template <class t>
inline bool ckmin(t &x, t y) {
  if (x > y) {
    x = y;
    return 1;
  }
  return 0;
}
template <class t>
inline bool ckmax(t &x, t y) {
  if (x < y) {
    x = y;
    return 1;
  }
  return 0;
}
inline int lowbit(int x) { return x & (-x); }
const int MaxN = 5050;
std::vector<int> E[MaxN];
int f[MaxN][MaxN][2], lf[MaxN], g[MaxN][2], n;
inline void dfs(int u, int fa) {
  lf[u] = (E[u].size() == 1u);
  std::memset(f[u], 0x3f, sizeof f[u]);
  f[u][0][0] = f[u][lf[u]][1] = 0;
  for (auto v : E[u])
    if (v != fa) {
      dfs(v, u);
      for (int i = 0; i <= lf[u] + lf[v]; ++i) g[i][0] = g[i][1] = 0x3f3f3f3f;
      for (int i = 0; i <= lf[u]; ++i)
        for (int j = 0; j <= lf[v]; ++j)
          for (int k = 0; k < 2; ++k)
            for (int l = 0; l < 2; ++l)
              ckmin(g[i + j][k], f[u][i][k] + f[v][j][l] + (k ^ l));
      lf[u] += lf[v];
      for (int i = 0; i <= lf[u]; ++i)
        f[u][i][0] = g[i][0], f[u][i][1] = g[i][1];
    }
}
signed main(void) {
  read(n);
  register int u, v;
  for (int i = 1; i < n; ++i) read(u, v), E[u].push_back(v), E[v].push_back(u);
  if (n == 2) return std::puts("1"), 0;
  int rt = 0;
  for (int i = 1; !rt && i <= n; ++i)
    if (E[i].size() > 1u) rt = i;
  dfs(rt, 0);
  write(std::min(f[rt][lf[rt] >> 1][0], f[rt][lf[rt] >> 1][1])), putchar('\n');
  return 0;
}
