#include <bits/stdc++.h>
using namespace std;
const int maxn = 5010;
const int inf = 0x3f3f3f3f;
int f[maxn][maxn][2];
int g[2][maxn][2];
int leaves[maxn];
vector<int> node[maxn];
int n;
void getmin(int &x, int y) { x = min(x, y); }
void dfs(int u, int fa) {
  leaves[u] = 0;
  if (node[u].size() == 1) {
    leaves[u] = 1;
    f[u][0][0] = f[u][1][1] = 0;
    f[u][0][1] = f[u][1][0] = inf;
    return;
  }
  for (int i = 0; i < node[u].size(); i++) {
    int v = node[u][i];
    if (v != fa) dfs(v, u);
  }
  int p = 0;
  g[p][0][0] = g[p][0][1] = 0;
  for (int k = 0; k < node[u].size(); k++) {
    int v = node[u][k];
    if (v == fa) continue;
    memset(g[!p], 0x3f, sizeof(g[!p]));
    for (int i = 0; i <= leaves[u]; i++)
      for (int j = 0; j <= leaves[v]; j++)
        for (int a = 0; a < 2; a++)
          for (int b = 0; b < 2; b++)
            getmin(g[!p][i + j][a], g[p][i][a] + f[v][j][b] + (a != b));
    p = !p;
    leaves[u] += leaves[v];
  }
  memcpy(f[u], g[p], sizeof(g[p]));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    node[u].push_back(v);
    node[v].push_back(u);
  }
  if (n == 2) {
    printf("1\n");
    return 0;
  }
  int pos = 1;
  while (node[pos].size() == 1) pos++;
  dfs(pos, -1);
  printf("%d\n", min(f[pos][leaves[pos] / 2][0], f[pos][leaves[pos] / 2][1]));
  return 0;
}
