#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 10;
const int inf = 0x3f3f3f3f;
int read() {
  int ans = 0;
  bool f = 0;
  char ch = getchar();
  while (ch < '0' or ch > '9') {
    if (ch == '-') f = 1;
    ch = getchar();
  }
  while (ch >= '0' and ch <= '9') {
    ans = (ans << 1) + (ans << 3) + (ch ^ 48);
    ch = getchar();
  }
  return f ? ~ans + 1 : ans;
}
vector<int> g[maxn];
int n, u, v, dp[maxn][maxn][2], cnt[maxn], tot, h[maxn][2];
void dfs(int now, int fa) {
  dp[now][0][0] = 0;
  if (g[now].size() == 1)
    dp[now][1][1] = 0, cnt[now] = 1;
  else
    dp[now][0][1] = 0;
  bool vis = 0;
  for (auto to : g[now]) {
    if (to == fa) continue;
    dfs(to, now);
    for (int j = 0; j <= min(tot / 2, cnt[now]); ++j)
      h[j][1] = dp[now][j][1], h[j][0] = dp[now][j][0],
      dp[now][j][1] = dp[now][j][0] = inf;
    for (int i = min(tot / 2, cnt[now]); i >= 0; --i) {
      for (int j = 0; j <= min(tot / 2, cnt[to]); ++j)
        dp[now][i + j][1] = min(dp[now][i + j][1],
                                h[i][1] + min(dp[to][j][1], dp[to][j][0] + 1)),
                    dp[now][i + j][0] =
                        min(dp[now][i + j][0],
                            h[i][0] + min(dp[to][j][0], dp[to][j][1] + 1));
    }
    cnt[now] += cnt[to];
    vis = 1;
  }
}
int main() {
  n = read();
  for (int i = 1; i < n; ++i) {
    u = read(), v = read();
    g[u].push_back(v);
    g[v].push_back(u);
  }
  memset(dp, 0x3f, sizeof dp);
  for (int i = 1; i <= n; ++i)
    if (g[i].size() == 1) tot++;
  dfs(1, 0);
  cout << min(dp[1][tot / 2][0], dp[1][tot / 2][1]);
  return 0;
}
