#include <bits/stdc++.h>
using std::cin;
using std::cout;
const int N = 5007;
int n, tot, to[N << 1], nex[N << 1], head[N << 1];
int dp[N][N][2], g[N << 1][2], s[N], cnt[N];
bool leaf[N];
void add(int x, int y) {
  to[++tot] = y;
  nex[tot] = head[x];
  head[x] = tot;
}
void Dfs(int u, int fa) {
  if (leaf[u]) {
    dp[u][0][0] = dp[u][1][1] = 0;
    return;
  }
  dp[u][0][0] = dp[u][0][1] = 0;
  for (int i = head[u]; i; i = nex[i]) {
    int v = to[i];
    if (v == fa) continue;
    Dfs(v, u);
    memset(g, 0x3f, sizeof(g));
    for (int j = s[u]; j >= 0; --j) {
      for (int k = s[v]; k >= 0; --k) {
        g[j + k][0] = std::min(
            g[j + k][0], dp[u][j][0] + std::min(dp[v][k][0], dp[v][k][1] + 1));
        g[j + k][1] = std::min(
            g[j + k][1], dp[u][j][1] + std::min(dp[v][k][1], dp[v][k][0] + 1));
      }
    }
    memcpy(dp[u], g, sizeof(dp[u]));
    s[u] += s[v];
  }
}
int main() {
  std::ios::sync_with_stdio(0);
  cin >> n;
  if (n == 2) {
    cout << "1\n";
    return 0;
  }
  for (int i = 1, x, y; i < n; ++i) {
    cin >> x >> y;
    add(x, y);
    add(y, x);
    ++cnt[x];
    ++cnt[y];
  }
  int rt = 0;
  for (int i = 1; i <= n; ++i) {
    if (cnt[i] == 1)
      leaf[i] = s[i] = 1;
    else
      rt = i;
  }
  memset(dp, 0x3f, sizeof(dp));
  Dfs(rt, 0);
  cout << std::min(dp[rt][s[rt] / 2][0], dp[rt][s[rt] / 2][1]) << '\n';
  return 0;
}
