#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
inline int read() {
  char c = getchar();
  int x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
int n, m, rt, res;
struct edge {
  int to, nxt;
} e[5005 << 1];
int tot, head[5005];
inline void adde(int u, int v) {
  e[++tot] = (edge){v, head[u]};
  head[u] = tot;
}
int d[5005];
int dp[5005][5005][2], sz[5005], g[2];
void dfs(int u, int pa) {
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == pa) continue;
    dfs(v, u);
    sz[u] += sz[v];
    if (sz[u] == sz[v]) {
      for (register int j = (0); j <= (sz[v]); ++j) {
        dp[u][j][0] = min(dp[v][j][0], dp[v][j][1] + 1);
        dp[u][j][1] = min(dp[v][j][1], dp[v][j][0] + 1);
      }
      continue;
    }
    for (register int j = (sz[u]); j >= (0); --j) {
      g[0] = g[1] = 0x3f3f3f3f;
      for (register int k = (0); k <= (min(sz[v], j)); ++k) {
        g[0] = min(g[0], min(dp[v][k][0], dp[v][k][1] + 1) + dp[u][j - k][0]);
        g[1] = min(g[1], min(dp[v][k][1], dp[v][k][0] + 1) + dp[u][j - k][1]);
      }
      for (register int k = (0); k <= (1); ++k) dp[u][j][k] = g[k];
    }
  }
  if (!sz[u]) {
    sz[u] = 1;
    dp[u][0][1] = dp[u][1][0] = 0;
    return;
  }
}
signed main() {
  memset(dp, 63, sizeof dp);
  n = read();
  if (n == 2) {
    puts("1");
    return 0;
  }
  for (register int i = (2); i <= (n); ++i) {
    int u = read(), v = read();
    adde(u, v);
    adde(v, u);
    d[u]++, d[v]++;
  }
  for (register int i = (1); i <= (n); ++i)
    if (d[i] > 1) {
      rt = i;
      break;
    }
  dfs(rt, 0);
  cout << min(dp[rt][sz[rt] / 2][0], dp[rt][sz[rt] / 2][1]);
  return 0;
}
