#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
const int oo = 1e9;
const int MX = 100000000;
int n, sz[N];
vector<int> g[N];
int dp[N][N][2];
void dfs(int u, int p) {
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i];
    if (v == p) continue;
    dfs(v, u);
    sz[u] += sz[v];
  }
  if (!sz[u]) sz[u]++;
  for (int i = 0; i <= sz[u]; ++i) dp[u][i][0] = dp[u][i][1] = oo;
  if (sz[u] == 1) dp[u][1][0] = dp[u][0][1] = 0;
  int all = 0;
  if (sz[u] > 1) {
    dp[u][0][0] = dp[u][0][1] = 0;
    for (auto v : g[u]) {
      if (v == p) continue;
      all += sz[v];
      for (int rem = all; rem >= 0; --rem) {
        for (int my = 0; my <= 1; ++my) {
          int ret = oo;
          for (int take = 0; take <= min(rem, sz[v]); ++take)
            for (int nc = 0; nc <= 1; ++nc)
              ret = min(ret,
                        dp[v][take][nc] + (my != nc) + dp[u][rem - take][my]);
          dp[u][rem][my] = ret;
        }
      }
    }
  }
}
int main() {
  cin >> n;
  for (int u, v, i = 0; i < n - 1; ++i) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int root = -1;
  for (int i = 1; i <= n; ++i) {
    if (g[i].size() > 1) {
      root = i;
      break;
    }
  }
  dfs(root, -1);
  int f = sz[root] / 2;
  printf("%d\n", min(dp[root][f][1], dp[root][f][0]));
  return 0;
}
