#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int t, next;
  Edge() {}
  Edge(int a, int b) : t(a), next(b) {}
};
Edge e[10005];
int head[5005], d[5005], m;
int size[5005], f[5005][5005][2];
int p[5005][2];
void dfs(int x, int fa) {
  memset(f[x], 0x3f, sizeof(f[x]));
  if (d[x] == 1) {
    size[x] = 1;
    f[x][0][0] = f[x][1][1] = 0;
    return;
  }
  int cnt = 0;
  for (int i = head[x]; i; i = e[i].next)
    if (e[i].t != fa) {
      int u = e[i].t;
      dfs(u, x);
      int(*t1)[2] = f[x], (*t2)[2] = f[u];
      if (!cnt) {
        for (int j = 0; j <= size[u]; j++) {
          t1[j][0] = min(t2[j][0], t2[j][1] + 1);
          t1[j][1] = min(t2[j][1], t2[j][0] + 1);
        }
        size[x] += size[u];
      } else {
        memset(p, 0x3f, sizeof(p));
        for (int j = 0; j <= size[x]; j++)
          for (int k = 0; k <= size[u]; k++)
            if (j + k <= m) {
              p[j + k][0] =
                  min(p[j + k][0], t1[j][0] + min(t2[k][0], t2[k][1] + 1));
              p[j + k][1] =
                  min(p[j + k][1], t1[j][1] + min(t2[k][1], t2[k][0] + 1));
            }
        size[x] += size[u];
        size[x] = min(size[x], m);
        for (int j = 0; j <= size[x]; j++) {
          t1[j][0] = p[j][0];
          t1[j][1] = p[j][1];
        }
      }
      cnt++;
    }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[2 * i - 1] = Edge(y, head[x]);
    head[x] = 2 * i - 1;
    e[2 * i] = Edge(x, head[y]);
    head[y] = 2 * i;
    d[x]++;
    d[y]++;
  }
  if (n == 2) {
    puts("1");
    return 0;
  }
  int rt = 0;
  for (int i = 1; i <= n; i++)
    if (d[i] > 1)
      rt = i;
    else
      m++;
  m >>= 1;
  dfs(rt, 0);
  printf("%d\n", min(f[rt][m][0], f[rt][m][1]));
  return 0;
}
