#include <bits/stdc++.h>
using namespace std;
const int mo = 1e8 - 3;
const double eps = 1e-9;
inline int maxx(int a, int b) { return a > b ? a : b; }
inline int minn(int a, int b) { return a < b ? a : b; }
inline int abss(int A) { return A < 0 ? -A : A; }
inline int pf(int A) { return A * A; }
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + ch - 48;
    ch = getchar();
  }
  return x * f;
}
inline int ksm(int x, int y, int p) {
  int res = 1;
  while (y) {
    if (y & 1) res = res * x % p;
    x = x * x % p;
    y >>= 1;
  }
  return res;
}
int n, leaf, cnt, rot = 1;
int dp[5005][5005][2], hand[10005], in[5005], son[5005];
struct edge {
  int to, ne;
} e[10005];
inline void adda(int a, int b) {
  e[cnt].to = b;
  e[cnt].ne = hand[a];
  hand[a] = cnt++;
  return;
}
inline void dfs(int u, int fa) {
  if (in[u] == 1) {
    dp[u][1][1] = 0;
    dp[u][0][0] = 0;
    son[u] = 1;
    return;
  }
  bool vis = 0;
  for (register int i = hand[u]; ~i; i = e[i].ne) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs(v, u);
    if (!vis) {
      for (register int j = 0; j <= son[v]; j++) {
        dp[u][j][0] = minn(dp[v][j][0], dp[v][j][1] + 1);
        dp[u][j][1] = minn(dp[v][j][0] + 1, dp[v][j][1]);
      }
    } else {
      for (register int j = son[u] + son[v]; j >= 0; j--) {
        int a = 0x7f7f7f, b = 0x7f7f7f;
        for (register int k = 0; k <= minn(j, son[v]); k++) {
          a = minn(a, dp[u][j - k][0] + minn(dp[v][k][1] + 1, dp[v][k][0]));
          b = minn(b, dp[u][j - k][1] + minn(dp[v][k][0] + 1, dp[v][k][1]));
        }
        dp[u][j][0] = a;
        dp[u][j][1] = b;
      }
    }
    vis = 1;
    son[u] += son[v];
  }
}
int main() {
  memset(hand, -1, sizeof(hand));
  memset(dp, 0x7f7f7f, sizeof(dp));
  n = read();
  for (register int i = 1; i < n; i++) {
    int a = read(), b = read();
    adda(a, b);
    adda(b, a);
    in[a]++;
    in[b]++;
  }
  for (register int i = 1; i <= n; i++) {
    if (in[i] == 1)
      leaf++;
    else
      rot = i;
  }
  dfs(rot, 0);
  printf("%d", minn(dp[rot][leaf / 2][0], dp[rot][leaf / 2][1]));
  return 0;
}
