#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
const int INF = (int)1e9 + 7;
int head[MAXN], edge[MAXN << 1], next1[MAXN << 1], esz;
int num[MAXN], dp[MAXN][MAXN][2], dp2[MAXN][2], temp[MAXN][2];
void addedge(int u, int v) {
  edge[esz] = v;
  next1[esz] = head[u];
  head[u] = esz++;
}
void dfs(int u, int p) {
  int ok = 0;
  for (int i = head[u]; i + 1; i = next1[i]) {
    int v = edge[i];
    if (v == p) continue;
    ok = 1;
    dfs(v, u);
    num[u] += num[v];
  }
  if (!ok) {
    num[u] = 1;
    dp[u][0][1] = 0;
    dp[u][1][0] = 0;
    return;
  }
  int res = 0;
  dp2[0][0] = dp2[0][1] = 0;
  for (int i = head[u]; i + 1; i = next1[i]) {
    int v = edge[i];
    if (v == p) continue;
    for (int j = 0; j <= res + num[v]; j++) temp[j][0] = temp[j][1] = INF;
    for (int id = 0; id < 2; id++)
      for (int j = 0; j <= res; j++)
        for (int z = 0; z <= num[v]; z++) {
          temp[j + z][id] =
              min(temp[j + z][id], dp2[j][id] + dp[v][z][0] + (id != 0));
          temp[j + z][id] =
              min(temp[j + z][id], dp2[j][id] + dp[v][z][1] + (id != 1));
        }
    for (int j = 0; j <= res + num[v]; j++) {
      dp2[j][0] = temp[j][0];
      dp2[j][1] = temp[j][1];
    }
    res += num[v];
  }
  for (int i = 0; i <= res; i++) {
    dp[u][i][0] = dp2[i][0];
    dp[u][i][1] = dp2[i][1];
  }
}
int main() {
  int n;
  memset(head, -1, sizeof(head));
  scanf("%d", &n);
  for (int j = 1; j <= n; j++)
    for (int i = 0; i <= n; i++) dp[j][i][0] = dp[j][i][1] = INF;
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    addedge(u, v);
    addedge(v, u);
  }
  if (n == 2) {
    printf("%d\n", 1);
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    int ok = 0;
    for (int j = head[i]; j + 1; j = next1[j]) {
      ok++;
    }
    if (ok > 1) {
      dfs(i, 0);
      printf("%d\n", min(dp[i][num[i] >> 1][0], dp[i][num[i] >> 1][1]));
      return 0;
    }
  }
  return 0;
}
