#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 9;
struct node {
  int last;
  int to;
} e[N << 1];
int head[N];
int cnt;
int size[N];
int f[N][2][N];
int n;
int root;
bool vis[N];
int leaf;
int ind[N];
int g[N][3];
void add(int from, int to) {
  e[++cnt].last = head[from];
  e[cnt].to = to;
  head[from] = cnt;
}
int read() {
  int f = 1, x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x << 1) + (x << 3) + (s ^ '0');
    s = getchar();
  }
  return f * x;
}
void prepare() {
  memset(f, 0x3f3f3f3f, sizeof(f));
  for (int i = 1; i <= n; i++) {
    if (ind[i] == 1) {
      leaf++;
      vis[i] = true;
    } else if (ind[i] > 1)
      if (!root) root = i;
  }
}
void copy(int u, int mx) {
  for (int j = 0; j <= mx; j++)
    for (int k = 0; k <= 1; k++) {
      g[j][k] = f[u][k][j];
      f[u][k][j] = 0x3f3f3f3f;
    }
}
void DP(int u, int fa) {
  bool flag = false;
  if (vis[u]) {
    size[u] = 1;
    f[u][1][1] = 0;
    f[u][0][0] = 0;
    return;
  }
  for (int i = head[u]; i; i = e[i].last) {
    int v = e[i].to;
    if (v == fa) continue;
    DP(v, u);
    if (!flag)
      for (int j = 0; j <= size[v]; j++) {
        f[u][1][j] = min(f[v][1][j], f[v][0][j] + 1);
        f[u][0][j] = min(f[v][1][j] + 1, f[v][0][j]);
      }
    else {
      copy(u, min(leaf / 2, size[u]));
      for (int j = 0; j <= min(leaf / 2, size[u]); j++)
        for (int k = 0; k <= min(leaf / 2, size[v]); k++) {
          f[u][0][j + k] =
              min(f[u][0][j + k], g[j][0] + min(f[v][0][k], f[v][1][k] + 1));
          f[u][1][j + k] =
              min(f[u][1][j + k], g[j][1] + min(f[v][1][k], f[v][0][k] + 1));
        }
    }
    flag = true;
    size[u] += size[v];
  }
}
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    int u = read();
    int v = read();
    add(u, v);
    add(v, u);
    ind[u]++;
    ind[v]++;
  }
  prepare();
  DP(root, 0);
  printf("%d\n", min(f[root][1][leaf / 2], f[root][0][leaf / 2]));
  return 0;
}
