#include <bits/stdc++.h>
using namespace std;
const int maxn = 5010, maxm = 10010;
using namespace std;
int n, m, pre[maxm], now[maxn], son[maxm], val[maxm], f[maxn][maxn][2],
    g[maxn][2], siz[maxn], tot, in[maxn];
bool isl[maxn];
void add(int a, int b) {
  pre[++tot] = now[a], now[a] = tot, son[tot] = b, in[b]++;
}
void dfs(int x, int fa) {
  if (isl[x]) {
    siz[x] = 1, f[x][0][0] = f[x][1][1] = 0;
    return;
  }
  f[x][0][0] = f[x][0][1] = 0;
  for (int y = now[x]; y; y = pre[y])
    if (son[y] != fa) {
      dfs(son[y], x);
      memset(g, 63, sizeof(g));
      for (int i = siz[x]; i >= 0; i--)
        for (int j = siz[son[y]]; j >= 0; j--) {
          g[i + j][0] = min(g[i + j][0], f[x][i][0] + f[son[y]][j][0]);
          g[i + j][1] = min(g[i + j][1], f[x][i][1] + f[son[y]][j][1]);
          g[i + j][0] = min(g[i + j][0], f[x][i][0] + f[son[y]][j][1] + 1);
          g[i + j][1] = min(g[i + j][1], f[x][i][1] + f[son[y]][j][0] + 1);
        }
      memcpy(f[x], g, sizeof(f[x]));
      siz[x] += siz[son[y]];
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1, a, b; i < n; i++) scanf("%d%d", &a, &b), add(a, b), add(b, a);
  if (n == 2) {
    printf("1");
    return 0;
  }
  for (int i = 1; i <= n; i++) isl[i] = (in[i] == 1);
  memset(f, 63, sizeof(f));
  for (int i = 1; i <= n; i++)
    if (in[i] != 1) {
      dfs(i, 0);
      printf("%d\n", min(f[i][siz[i] >> 1][0], f[i][siz[i] >> 1][1]));
      return 0;
    }
}
