#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 100;
const int INF = 0x3f3f3f3f;
int n;
vector<int> g[N];
int dp[N][N][2];
int dfs(int v, int fa) {
  int tot = 0, now = 0;
  dp[v][0][0] = 0;
  dp[v][0][1] = 0;
  int f = 1;
  for (int i = 0; i < g[v].size(); i++) {
    if (g[v][i] == fa) continue;
    int u = g[v][i];
    f = 0;
    now = dfs(g[v][i], v);
    tot += now;
    for (int k = tot; k >= 0; k--) {
      int max0 = INF, max1 = INF;
      for (int j = 0; j <= now; j++) {
        max0 = min(max0, min(dp[v][k - j][0] + dp[u][j][0],
                             dp[v][k - j][0] + dp[u][j][1] + 1));
        max1 = min(max1, min(dp[v][k - j][1] + dp[u][j][1],
                             dp[v][k - j][1] + dp[u][j][0] + 1));
      }
      dp[v][k][0] = max0;
      dp[v][k][1] = max1;
    }
  }
  if (f) {
    dp[v][1][0] = INF;
    dp[v][0][1] = INF;
    dp[v][1][1] = 0;
  }
  return tot + f;
}
int main(void) {
  int a, b;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  if (n == 2)
    puts("1");
  else {
    int leaf = 0;
    int root = -1;
    for (int i = 1; i <= n; i++) {
      if (g[i].size() == 1)
        leaf++;
      else if (root == -1)
        root = i;
    }
    memset(dp, INF, sizeof(dp));
    dfs(root, root);
    printf("%d\n", min(dp[root][leaf / 2][0], dp[root][leaf / 2][1]));
  }
  return 0;
}
