#include <bits/stdc++.h>
using namespace std;
long long int Pow(long long int a, long long int b, long long int md,
                  long long int ans = 1) {
  for (; b; b >>= 1, a = a * a % md)
    if (b & 1) ans = ans * a % md;
  return ans;
}
const long long int MAXN = 5e3 + 10;
const long long int INF = 1e18;
const long long int MOD = 1e9 + 7;
long long int M[MAXN], dp[MAXN][MAXN], pd[MAXN], n;
vector<long long int> adj[MAXN];
void DFS(long long int v, long long int p = -1) {
  if ((long long int)adj[v].size() == 1) M[v] = 1, dp[v][1] = 0;
  if ((long long int)adj[v].size() > 1) dp[v][0] = 0;
  for (long long int u : adj[v]) {
    if (u != p) {
      DFS(u, v);
      for (long long int i = 0; i <= M[v]; i++) {
        for (long long int j = 0; j <= M[u]; j++) {
          pd[i + j] = min(
              {pd[i + j], dp[v][i] + dp[u][j], dp[v][i] + dp[u][M[u] - j] + 1});
        }
      }
      M[v] += M[u];
      for (long long int i = 0; i <= M[v]; i++) dp[v][i] = pd[i], pd[i] = INF;
    }
  }
}
int main() {
  for (long long int i = 0; i < MAXN; i++) fill(dp[i], dp[i] + MAXN, INF);
  fill(pd, pd + MAXN, INF);
  scanf("%lld", &n);
  for (long long int i = 1; i < n; i++) {
    long long int u, v;
    scanf("%lld%lld", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  DFS(1);
  printf("%lld\n", dp[1][M[1] / 2]);
  return 0;
}
