#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
const int M = 5005;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int n, inde[N], root = 1, siz[N], f[N][N][2], scnt;
struct edge {
  int v, nxt;
} e[M << 1];
int cnt, head[N];
void add_edge(int u, int v) {
  e[++cnt] = (edge){v, head[u]};
  head[u] = cnt;
}
void dfs(int x, int fa) {
  for (int i = head[x]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa) continue;
    dfs(v, x);
    siz[x] += siz[v];
  }
  if (!siz[x]) {
    siz[x] = 1;
    f[x][0][0] = f[x][1][1] = 0;
    scnt++;
    return;
  } else
    f[x][0][1] = f[x][0][0] = 0;
}
void dp(int x, int fa) {
  for (int i = head[x]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa) continue;
    dp(v, x);
    for (int j = siz[x]; j >= 0; j--) {
      int tmpa = 0x3f3f3f3f, tmpb = 0x3f3f3f3f;
      for (int k = 0; k <= siz[v]; ++k) {
        if (k > j) continue;
        tmpa = min(tmpa, f[x][j - k][0] + f[v][k][1] + 1);
        tmpa = min(tmpa, f[x][j - k][0] + f[v][k][0]);
        tmpb = min(tmpb, f[x][j - k][1] + f[v][k][1]);
        tmpb = min(tmpb, f[x][j - k][1] + f[v][k][0] + 1);
      }
      f[x][j][0] = tmpa;
      f[x][j][1] = tmpb;
    }
  }
}
int main() {
  n = read();
  for (int i = 1, u, v; i < n; i++) {
    u = read(), v = read();
    add_edge(u, v), add_edge(v, u);
    inde[u]++, inde[v]++;
  }
  memset(f, 0x3f, sizeof f);
  while (inde[root] == 1) root++;
  dfs(root, 0);
  dp(root, 0);
  printf("%d", min(f[root][scnt >> 1][0], f[root][scnt >> 1][1]));
  puts("");
  return 0;
}
