#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5000 + 5;
const int INF = 0x3f3f3f3f;
struct edge {
  int to, nxt;
} e[MAXN << 1];
int head[MAXN], tot;
int deg[MAXN], vis[MAXN], sz[MAXN << 1];
int dp[MAXN][MAXN][2];
void init() {
  tot = 0;
  memset(head, -1, sizeof(head));
}
void addedge(int u, int v) {
  e[tot].to = v;
  e[tot].nxt = head[u];
  head[u] = tot++;
}
void update(int &x, int y) { x = x < y ? x : y; }
void dfs(int u) {
  vis[u] = 1;
  int f = 0;
  for (int i = 0; i < MAXN; i++) dp[u][i][1] = dp[u][i][0] = INF;
  for (int i = head[u]; i != -1; i = e[i].nxt) {
    int v = e[i].to;
    if (vis[v]) continue;
    f++;
    if (f == 1) {
      dp[u][0][0] = dp[u][0][1] = 0;
    }
    dfs(v);
    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 {
          update(dp[u][j + k][0],
                 min(dp[u][j][0] + dp[v][k][1] + 1, dp[u][j][0] + dp[v][k][0]));
          update(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 (f == 0) {
    dp[u][1][1] = dp[u][0][0] = 0;
    sz[u] = 1;
  }
}
int main() {
  int n, u, v;
  scanf("%d", &n);
  if (n == 2) {
    puts("1");
    return 0;
  }
  init();
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    addedge(u, v);
    addedge(v, u);
    deg[u]++;
    deg[v]++;
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (deg[i] == 1) cnt++;
  }
  for (int i = 1; i <= n; i++) {
    if (deg[i] > 1) {
      dfs(i);
      printf("%d\n", min(dp[i][cnt / 2][0], dp[i][cnt / 2][1]));
      break;
    }
  }
  return 0;
}
