#include <bits/stdc++.h>
const int maxn = 5005, maxm = maxn << 1;
int n, e, leaf, rt, stp;
int start[maxn], to[maxm], then[maxm], f[maxn][maxn][2], deg[maxn], size[maxn],
    g[maxn][2];
inline void add(int x, int y) {
  then[++e] = start[x], start[x] = e, to[e] = y, deg[y]++;
}
inline int min(int a, int b) { return a < b ? a : b; }
void dfs(int x, int last) {
  size[x] = 1;
  if (deg[x] == 1) {
    leaf++;
    f[x][0][0] = f[x][1][1] = 0;
    return;
  }
  f[x][0][0] = f[x][0][1] = 0;
  for (int i = start[x]; i; i = then[i]) {
    int y = to[i];
    if (y == last) continue;
    dfs(y, x);
    for (int j = 0; j <= size[x] + size[y]; j++) g[j][0] = g[j][1] = 0x3f3f3f3f;
    for (int j = 0; j <= size[x]; j++)
      for (int k = 0; k <= size[y]; k++) {
        g[j + k][0] =
            min(g[j + k][0], f[x][j][0] + min(f[y][k][0], f[y][k][1] + 1));
        g[j + k][1] =
            min(g[j + k][1], f[x][j][1] + min(f[y][k][0] + 1, f[y][k][1]));
      }
    size[x] += size[y];
    for (int i = 0; i <= size[x]; i++)
      f[x][i][0] = g[i][0], f[x][i][1] = g[i][1];
  }
}
int main() {
  memset(f, 0x3f, sizeof(f));
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y), add(y, x);
  }
  if (n == 2) {
    puts("1");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (deg[i] > 1) {
      rt = i;
      break;
    }
  dfs(rt, 0);
  printf("%d\n", f[rt][leaf / 2][0]);
  return 0;
}
