#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from, to, next;
} e[100005];
int head[5555], tot, cnt[5555];
void add(int a, int b) {
  e[tot].from = a, e[tot].to = b, e[tot].next = head[a], head[a] = tot++;
}
int dp[5555][5555];
int n;
void dfs(int rt, int fa) {
  dp[rt][0] = 0;
  for (int i = 1; i <= n; i++) dp[rt][i] = n + 1;
  if (e[head[rt]].next == -1)
    cnt[rt] = 1;
  else
    cnt[rt] = 0;
  vector<int> rec;
  for (int i = head[rt]; i != -1; i = e[i].next) {
    int to = e[i].to;
    if (to == fa) continue;
    dfs(to, rt);
    rec.push_back(to);
  }
  for (int k = 0; k < rec.size(); k++) {
    int to = rec[k];
    for (int i = cnt[rt]; i >= 0; i--) {
      for (int j = 0; j <= cnt[to]; j++) {
        dp[rt][i + j] = min(dp[rt][i + j], dp[rt][i] + dp[to][j]);
      }
    }
    cnt[rt] = cnt[rt] + cnt[to];
  }
  for (int i = 0; i <= cnt[rt]; i++)
    dp[rt][i] = min(dp[rt][i], dp[rt][cnt[rt] - i] + 1);
}
int main() {
  while (~scanf("%d", &n)) {
    if (n == 2) {
      printf("1\n");
      continue;
    }
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i <= n; i++) {
      head[i] = -1;
      cnt[i] = 0;
    }
    tot = 0;
    for (int i = 0; i < n - 1; i++) {
      int a, b;
      scanf("%d%d", &a, &b);
      add(a, b);
      add(b, a);
    }
    int st = 1;
    while (e[head[st]].next == -1) st++;
    dfs(st, -1);
    printf("%d\n", dp[st][cnt[st] / 2]);
  }
}
