#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 10, inf = 0x3f3f3f3f;
int dp[maxn][maxn][2], leaf[maxn];
vector<int> tree[maxn];
void dfs(int u, int fa) {
  int sz = tree[u].size();
  if (sz == 1) {
    leaf[u] = 1;
    dp[u][0][0] = dp[u][1][1] = 0;
  } else {
    dp[u][0][0] = dp[u][0][1] = 0;
  }
  for (int i = 0; i < sz; i++) {
    int v = tree[u][i];
    if (v == fa) continue;
    dfs(v, u);
    leaf[u] += leaf[v];
    for (int j = leaf[u]; j >= 0; j--) {
      int temp[2] = {inf, inf};
      for (int k = 0; k <= leaf[v]; k++) {
        temp[0] = min(temp[0], min(dp[u][j - k][0] + dp[v][k][1] + 1,
                                   dp[u][j - k][0] + dp[v][k][0]));
        temp[1] = min(temp[1], min(dp[u][j - k][1] + dp[v][k][0] + 1,
                                   dp[u][j - k][1] + dp[v][k][1]));
      }
      for (int k = 0; k < 2; k++) dp[u][j][k] = temp[k];
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    tree[u].push_back(v);
    tree[v].push_back(u);
  }
  memset(dp, inf, sizeof dp);
  if (n == 2) {
    printf("1");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (tree[i].size() > 1) {
      dfs(i, -1);
      printf("%d\n", min(dp[i][leaf[i] / 2][0], dp[i][leaf[i] / 2][1]));
      break;
    }
  }
}
