#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
int h[N], cnt[N], deg[N];
int f[N][2][N];
int n, m, tot, x, y, root;
struct edge {
  int y, next;
} g[N * 2];
void adp(int x, int y) {
  g[++tot].y = y;
  g[tot].next = h[x];
  h[x] = tot;
}
void dfs(int x, int fa) {
  if (deg[x] == 1)
    cnt[x] = 1, f[x][1][0] = f[x][0][1] = 0;
  else
    f[x][1][0] = f[x][0][0] = 0;
  for (int i = h[x]; i; i = g[i].next)
    if (g[i].y != fa) {
      dfs(g[i].y, x);
      for (int k = cnt[x] + cnt[g[i].y]; k >= 0; k--) {
        int mn0 = 1e9, mn1 = 1e9;
        for (int cx = max(k - cnt[g[i].y], 0); cx <= min(cnt[x], k); cx++) {
          mn0 = min(mn0, min(f[x][0][cx] + f[g[i].y][0][k - cx],
                             f[x][0][cx] + 1 + f[g[i].y][1][k - cx]));
          mn1 = min(mn1, min(f[x][1][cx] + 1 + f[g[i].y][0][k - cx],
                             f[x][1][cx] + f[g[i].y][1][k - cx]));
        }
        f[x][0][k] = mn0;
        f[x][1][k] = mn1;
      }
      cnt[x] += cnt[g[i].y];
    }
}
int main() {
  scanf("%d", &n);
  if (n == 2) {
    printf("1\n");
    return 0;
  }
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    adp(x, y);
    adp(y, x);
    deg[x]++;
    deg[y]++;
  }
  for (int i = 1; i <= n; i++)
    if (deg[i] != 1) {
      root = i;
      break;
    }
  memset(f, 0x16, sizeof(f));
  dfs(root, 0);
  printf("%d\n", min(f[root][0][cnt[root] / 2], f[root][1][cnt[root] / 2]));
}
