#include <bits/stdc++.h>
using namespace std;
int n, tot, rt, sz[5010], deg[5010], head[5010], ver[5010 * 2], Next[5010 * 2],
    f[5010][2], dp[5010][5010][2];
void add(int u, int v) {
  ver[++tot] = v;
  Next[tot] = head[u];
  head[u] = tot;
  deg[u]++;
}
void dfs(int u, int fa) {
  if (deg[u] == 1) {
    dp[u][1][1] = dp[u][0][0] = 0;
    return;
  }
  dp[u][0][0] = dp[u][0][1] = 0;
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    if (v == fa) continue;
    dfs(v, u);
    sz[u] += sz[v];
    memset(f, 0x3f, sizeof(f));
    for (int j = sz[u]; ~j; j--) {
      for (int k = sz[v]; ~k; k--) {
        f[j][0] =
            min(f[j][0], dp[u][j - k][0] + min(dp[v][k][0], dp[v][k][1] + 1));
        f[j][1] =
            min(f[j][1], dp[u][j - k][1] + min(dp[v][k][0] + 1, dp[v][k][1]));
      }
    }
    for (int j = sz[u]; ~j; j--) dp[u][j][0] = f[j][0], dp[u][j][1] = f[j][1];
  }
}
int main() {
  memset(dp, 0x3f, sizeof(dp));
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  for (int i = 1; i <= n; i++) sz[i] = (deg[i] == 1);
  rt = 1;
  while (deg[rt] == 1) rt++;
  dfs(rt, 0);
  printf("%d\n", min(dp[rt][sz[rt] / 2][0], dp[rt][sz[rt] / 2][1]));
  return 0;
}
