#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int n, head[N], cnt, f[N][N][2], sz[N], deg[N], g[N][2], rt;
struct Edge {
  int v, nx;
} e[N << 1];
inline int read() {
  int ret = 0, ff = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    ret = ret * 10 + (ch ^ 48);
    ch = getchar();
  }
  return ret * ff;
}
void write(int x) {
  if (x < 0) {
    x = -x, putchar('-');
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + 48);
}
void writeln(int x) { write(x), puts(""); }
void writesp(int x) { write(x), putchar(' '); }
void add(int x, int y) {
  e[++cnt].v = y;
  e[cnt].nx = head[x];
  head[x] = cnt;
}
void dfs(int u, int fa) {
  if (deg[u] > 1)
    f[u][0][0] = f[u][0][1] = 0;
  else
    sz[u] = 1, f[u][0][1] = f[u][1][0] = 0;
  for (int t = head[u]; t; t = e[t].nx) {
    int v = e[t].v;
    if (v == fa) continue;
    dfs(v, u);
    memset(g, 0x3f, sizeof(g));
    for (int i = 0; i <= sz[u]; i++) {
      for (int j = 0; j <= sz[v]; j++) {
        g[i + j][0] = min(g[i + j][0], min(f[u][i][0] + f[v][j][0],
                                           f[u][i][0] + f[v][j][1] + 1));
        g[i + j][1] = min(g[i + j][1], min(f[u][i][1] + f[v][j][0] + 1,
                                           f[u][i][1] + f[v][j][1]));
      }
    }
    sz[u] += sz[v];
    for (int i = 0; i <= sz[u]; i++) f[u][i][0] = g[i][0], f[u][i][1] = g[i][1];
  }
}
signed main() {
  n = read();
  if (n == 2) {
    write(1);
    return 0;
  }
  for (int i = 1; i < n; i++) {
    int x = read(), y = read();
    add(x, y), add(y, x);
    deg[x]++, deg[y]++;
  }
  for (int i = 1; i <= n; i++)
    if (deg[i] > 1) rt = i;
  memset(f, 0x3f, sizeof(f));
  dfs(rt, 0);
  write(min(f[rt][sz[rt] / 2][0], f[rt][sz[rt] / 2][1]));
  return 0;
}
