#include <bits/stdc++.h>
using namespace std;
const int M = 5e3 + 7;
const int INF = 1e9 + 7;
inline int ri() {
  int x = 0;
  bool f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = 0;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  return f ? x : -x;
}
int n;
int du[M];
int cnt[M];
int f[M][2][M];
int tp[2];
struct vec {
  int g[M], te;
  struct edge {
    int y, nxt;
    edge(int _y = 0, int _nxt = 0) { y = _y, nxt = _nxt; }
  } e[M << 1];
  vec() {
    memset(g, 0, sizeof g);
    te = 0;
  }
  inline void push(int x, int y) {
    e[++te] = edge(y, g[x]);
    g[x] = te;
  }
  inline void push2(int x, int y) {
    push(x, y);
    push(y, x);
  }
  inline int& operator()(int x) { return g[x]; }
  inline edge& operator[](int x) { return e[x]; }
} e;
void dfs(int x, int fa) {
  int p, y, i, j, k;
  if (du[x] == 1) {
    cnt[x] = 1;
    f[x][0][1] = 0;
    f[x][1][0] = 0;
  } else {
    cnt[x] = 0;
    f[x][0][0] = 0;
    f[x][1][0] = 0;
  }
  for (p = e(x); p; p = e[p].nxt)
    if ((y = e[p].y) != fa) {
      dfs(y, x);
      for (k = cnt[x] + cnt[y]; k >= 0; k--) {
        tp[0] = tp[1] = INF;
        for (i = max(k - cnt[y], 0); i <= min(cnt[x], k); i++) {
          j = k - i;
          tp[0] = min(
              tp[0], min(f[x][0][i] + f[y][0][j], f[x][0][i] + 1 + f[y][1][j]));
          tp[1] = min(
              tp[1], min(f[x][1][i] + f[y][1][j], f[x][1][i] + 1 + f[y][0][j]));
        }
        f[x][0][k] = tp[0];
        f[x][1][k] = tp[1];
      }
      cnt[x] += cnt[y];
    }
}
int main() {
  int i, x, y;
  n = ri();
  for (i = 1; i < n; i++) {
    x = ri(), y = ri();
    e.push2(x, y);
    du[x]++;
    du[y]++;
  }
  if (n == 2) {
    puts("1");
    return 0;
  }
  memset(f, 0x3f, sizeof f);
  for (i = 1; i <= n; i++)
    if (du[i] != 1) {
      dfs(i, 0);
      printf("%d\n", min(f[i][0][cnt[i] / 2], f[i][1][cnt[i] / 2]));
      return 0;
    }
  return 0;
}
