#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
const int INF = 1e9 + 5;
const int M = 2 * N;
int dp[N][N][2], fst[N], nxt[M], num[N], v[M];
int tot, cnt[N], rt, n;
void build(int x, int y) {
  cnt[x]++;
  v[tot] = y;
  nxt[tot] = fst[x];
  fst[x] = tot++;
}
void dpit(int x, int pa) {
  int y, mn;
  if (cnt[x] == 1) {
    dp[x][1][0] = dp[x][0][1] = 0;
    num[x] = 1;
    return;
  }
  num[x] = 0;
  dp[x][0][1] = dp[x][0][0] = 0;
  for (int p = fst[x]; ~p; p = nxt[p]) {
    y = v[p];
    if (y == pa) continue;
    dpit(y, x);
    num[x] += num[y];
    for (int(cx) = 0; (cx) < 2; cx++) {
      for (int j = num[x]; j >= 0; j--) {
        mn = INF;
        for (int k = 0; k <= j && k <= num[y]; k++)
          for (int(cy) = 0; (cy) < 2; cy++)
            mn = min(mn, dp[x][j - k][cx] + dp[y][k][cy] + (cx ^ cy));
        dp[x][j][cx] = mn;
      }
    }
  }
}
int main() {
  int x, y;
  scanf("%d", &n);
  tot = 0;
  memset(fst, -1, sizeof(fst));
  for (int(i) = 0; (i) < n - 1; i++) {
    scanf("%d%d", &x, &y);
    x--;
    y--;
    build(x, y);
    build(y, x);
  }
  memset(dp, 0x3F, sizeof(dp));
  rt = -1;
  for (int(i) = 0; (i) < n; i++)
    if (cnt[i] > 1) rt = i;
  if (rt == -1)
    puts("1");
  else {
    dpit(rt, -1);
    printf("%d\n", min(dp[rt][num[rt] / 2][0], dp[rt][num[rt] / 2][1]));
  }
  return 0;
}
