#include <bits/stdc++.h>
using namespace std;
const int maxn = 5050;
const int inf = 0x3f3f3f3f;
vector<int> G[maxn];
int n;
int dp[maxn][maxn][2];
int sz[maxn];
void dfs(int u, int fa) {
  if (G[u].size() != 1) dp[u][0][0] = dp[u][0][1] = 0;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa) continue;
    dfs(v, u);
    for (int j = sz[u]; j >= 0; j--)
      for (int k = sz[v]; k >= 0; k--)
        if (j == sz[u] || k == 0) {
          dp[u][j + k][0] =
              min(dp[u][j][0] + dp[v][k][1] + 1, dp[u][j][0] + dp[v][k][0]);
          dp[u][j + k][1] =
              min(dp[u][j][1] + dp[v][k][0] + 1, dp[u][j][1] + dp[v][k][1]);
        } else {
          dp[u][j + k][0] = min(
              dp[u][j + k][0],
              min(dp[u][j][0] + dp[v][k][1] + 1, dp[u][j][0] + dp[v][k][0]));
          dp[u][j + k][1] = min(
              dp[u][j + k][1],
              min(dp[u][j][1] + dp[v][k][0] + 1, dp[u][j][1] + dp[v][k][1]));
        }
    sz[u] += sz[v];
  }
  if (G[u].size() == 1) {
    sz[u] = 1;
    dp[u][0][0] = dp[u][1][1] = 0;
  }
}
int main() {
  int a, b;
  scanf("%d", &n);
  if (n == 2) {
    puts("1");
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int root = 1;
  int tt = 0;
  for (int i = 1; i <= n; i++)
    if (G[i].size() == 1) tt++;
  while (G[root].size() == 1) root++;
  memset(dp, inf, sizeof(dp));
  dfs(root, -1);
  printf("%d\n", min(dp[root][tt / 2][0], dp[root][tt / 2][1]));
  return 0;
}
