#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592653589793;
int n, ans;
int f[5010];
int head;
vector<int> edge[5010];
queue<int> st;
int bfsx[5010];
int dp[5010][5010][2];
int num[5010], cnt;
void bfs() {
  int x, y, cnt = 0;
  st.push(head);
  while (!st.empty()) {
    x = st.front();
    bfsx[++cnt] = x;
    for (int i = edge[x].size() - 1; i >= 0; i--) {
      y = edge[x][i];
      if (f[x] != y) {
        f[y] = x;
        st.push(y);
      }
    }
    st.pop();
  }
}
void init() {
  int x, y;
  ans = 0;
  scanf("%d", &n);
  memset(dp, 0xf, sizeof(dp));
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  for (int i = 1; i <= n; i++)
    if (edge[i].size() > 1) {
      head = i;
      f[head] = 0;
      break;
    }
  cnt = 0;
  for (int i = 1; i <= n; i++)
    if (edge[i].size() == 1) {
      dp[i][0][0] = 0;
      dp[i][1][1] = 0;
      cnt++;
      num[i] = 1;
    } else {
      dp[i][0][0] = 0;
      dp[i][0][1] = 0;
      num[i] = 0;
    }
  bfs();
}
void work() {
  int p, np;
  if (n == 2) {
    printf("1\n");
    return;
  }
  for (int i = n; i >= 1; i--) {
    p = bfsx[i];
    num[f[p]] += num[p];
    num[f[p]] = min(num[f[p]], cnt / 2);
    for (int j = num[f[p]]; j >= 0; j--) {
      for (int s = 0; s <= 1; s++)
        dp[f[p]][j][s] += min(dp[p][0][s], dp[p][0][!s] + 1);
      for (int k = min(j, num[p]); k > 0; k--) {
        for (int s = 0; s <= 1; s++)
          dp[f[p]][j][s] =
              min(dp[f[p]][j][s],
                  dp[f[p]][j - k][s] + min(dp[p][k][s], dp[p][k][!s] + 1));
      }
    }
  }
  ans = min(dp[head][cnt / 2][0], dp[head][cnt / 2][1]);
  printf("%d\n", ans);
}
int main() {
  init();
  work();
  return 0;
}
