#include <bits/stdc++.h>
const int INF = 1000000000;
using namespace ::std;
int n, m, root;
bool chk[5000 + 5];
vector<int> ad[5000 + 5];
int dp[5000 + 5][5000 + 5];
int end_num[5000 + 5];
void input() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int v1, v2;
    scanf("%d %d", &v1, &v2);
    ad[v1].push_back(v2);
    ad[v2].push_back(v1);
  }
  for (int i = 1; i <= n; i++) {
    if (ad[i].size() == 1)
      m++;
    else
      root = i;
    for (int j = 1; j <= n; j++) dp[i][j] = INF;
  }
  m /= 2;
}
void update_dp(int now, int next) {
  end_num[now] += end_num[next];
  for (int i = end_num[now]; i >= 0; i--) {
    for (int j = 0; j <= end_num[next] && j <= i; j++) {
      dp[now][i] = min(dp[now][i], dp[now][i - j] + dp[next][j]);
      dp[now][i] =
          min(dp[now][i], dp[now][i - j] + dp[next][end_num[next] - j] + 1);
    }
  }
}
void get_dp(int now) {
  chk[now] = true;
  for (auto &next : ad[now]) {
    if (!chk[next]) {
      get_dp(next);
      update_dp(now, next);
    }
  }
  if (end_num[now] == 0) dp[now][++end_num[now]] = 1;
}
int main() {
  input();
  if (n == 2)
    printf("1");
  else {
    get_dp(root);
    printf("%d", dp[root][m]);
  }
  return 0;
}
