#include <bits/stdc++.h>
using namespace std;
const int INF = 1e5 + 15;
const int maxn = 5050;
struct node {
  int id, next;
} E[maxn << 1];
int head[maxn], tot;
void init() {
  memset(head, -1, sizeof(head));
  tot = 0;
}
void adde(int u, int v) {
  E[tot].id = v;
  E[tot].next = head[u];
  head[u] = tot++;
}
int N, u, v;
int du[maxn], num_of_leaf, root, siz[maxn];
int dp[maxn][maxn][2];
void DFS(int u, int p) {
  dp[u][0][0] = 0, dp[u][0][1] = 0;
  if (du[u] == 1) {
    dp[u][1][1] = 0;
    dp[u][0][1] = INF;
    return;
  }
  for (int i = head[u]; ~i; i = E[i].next) {
    int v = E[i].id;
    if (v == p) continue;
    DFS(v, u);
    siz[u] += siz[v];
    for (int j = min(siz[u], num_of_leaf); j >= 0; j--) {
      int ans[2] = {INF, INF};
      for (int k = 0; k <= siz[v] && k <= j; k++) {
        ans[0] = min(ans[0], min(dp[u][j - k][0] + dp[v][k][1] + 1,
                                 dp[u][j - k][0] + dp[v][k][0]));
        ans[1] = min(ans[1], min(dp[u][j - k][1] + dp[v][k][0] + 1,
                                 dp[u][j - k][1] + dp[v][k][1]));
      }
      dp[u][j][0] = ans[0];
      dp[u][j][1] = ans[1];
    }
  }
}
int main() {
  init();
  memset(dp, 0x3f3f3f3f, sizeof(dp));
  scanf("%d", &N);
  for (int i = 1; i < N; i++) {
    scanf("%d%d", &u, &v);
    adde(u, v);
    adde(v, u);
    du[u]++;
    du[v]++;
  }
  for (int i = 1; i <= N; i++) {
    if (du[i] == 1)
      siz[i] = 1, num_of_leaf++;
    else
      root = i;
  }
  num_of_leaf >>= 1;
  DFS(root, -1);
  printf("%d\n", min(dp[root][num_of_leaf][0], dp[root][num_of_leaf][1]));
  return 0;
}
