#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char i = getchar();
  long long f = 1, res = 0;
  while (i < '0' || i > '9') {
    if (i == '-') f = -1;
    i = getchar();
  }
  while (i >= '0' && i <= '9') {
    res = res * 10 + i - '0';
    i = getchar();
  }
  return res * f;
}
const int N = 5e3 + 50;
int head[N], n, m, k = 0, in[N];
struct zk {
  int v, next;
} ed[N << 1];
int dp[N][N][2], rt, son[N], tmp[N][2];
inline void adde(int u, int v) {
  ed[++k].v = v;
  ed[k].next = head[u];
  head[u] = k;
}
inline void dfs(int u, int fa) {
  if (in[u] == 1) {
    dp[u][1][0] = dp[u][0][1] = 0;
    son[u] = 1;
    return;
  }
  son[u] = 0;
  dp[u][0][0] = dp[u][0][1] = 0;
  for (register int i = head[u]; ~i; i = ed[i].next) {
    int v = ed[i].v;
    if (v == fa) continue;
    dfs(v, u);
    memset(tmp, 0x3f, sizeof tmp);
    for (register int s1 = son[u]; s1 >= 0; --s1)
      for (register int s2 = son[v]; s2 >= 0; --s2) {
        tmp[s1 + s2][0] =
            min(tmp[s1 + s2][0],
                dp[u][s1][0] + min(dp[v][s2][0], dp[v][s2][1] + 1));
        tmp[s1 + s2][1] =
            min(tmp[s1 + s2][1],
                dp[u][s1][1] + min(dp[v][s2][0] + 1, dp[v][s2][1]));
      }
    son[u] += son[v];
    for (register int j = 0; j <= son[u]; ++j) {
      dp[u][j][0] = tmp[j][0];
      dp[u][j][1] = tmp[j][1];
    }
  }
}
int main() {
  n = read();
  int u, v;
  memset(head, -1, sizeof head);
  for (register int i = 1; i < n; ++i) {
    u = read();
    v = read();
    adde(u, v);
    adde(v, u);
    ++in[u], ++in[v];
  }
  rt = 1;
  while (rt < n && in[rt] == 1) ++rt;
  memset(dp, 0x3f, sizeof dp);
  dfs(rt, 0);
  int k = son[rt] >> 1;
  int ans = min(dp[rt][k][0], dp[rt][k][1]);
  printf("%d", ans);
}
