#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
vector<int> g[5005];
int d[2][5005][5005];
int n;
int v1, v2;
int buf[2][5005];
int leafs;
int root;
int cnt[5005];
int cl[5005];
void dfs(int v, int p) {
  cnt[v] = 1;
  for (int j = 0; j < g[v].size(); j++) {
    if (g[v][j] == p) {
      continue;
    }
    dfs(g[v][j], v);
    cnt[v] += cnt[g[v][j]];
    cl[v] += cl[g[v][j]];
  }
  if (cnt[v] == 1) {
    d[0][v][1] = 0;
    d[1][v][0] = 0;
    cl[v] = 1;
    return;
  }
  for (int it = 0; it < 2; it++) {
    int cur = 0;
    int cc = 0;
    buf[0][0] = 0;
    for (int j = 0; j < g[v].size(); j++) {
      if (g[v][j] == p) {
        continue;
      }
      cur = 1 ^ cur;
      memset(buf[cur], 127, sizeof(int) * (min(cc + cl[g[v][j]], leafs) + 2));
      for (int i = 0; i <= min(cc, leafs); i++) {
        for (int h = 0; h <= min(cl[g[v][j]], leafs - i); h++) {
          int delta =
              min(d[0][g[v][j]][h] + (it == 1), d[1][g[v][j]][h] + (it == 0));
          buf[cur][i + h] = min(buf[cur][i + h], buf[cur ^ 1][i] + delta);
        }
      }
      cc += cl[g[v][j]];
    }
    for (int j = 0; j <= min(leafs, cl[v]); j++) {
      d[it][v][j] = buf[cur][j];
    }
  }
}
void solve() {
  memset(d, 127, sizeof(d));
  scanf("%d", &n);
  if (n == 2) {
    printf("1\n");
    return;
  }
  for (int j = 1; j <= n; j++) {
    g[j].reserve(n);
  }
  for (int j = 1; j < n; j++) {
    scanf("%d%d", &v1, &v2);
    g[v1].push_back(v2);
    g[v2].push_back(v1);
  }
  for (int j = 1; j <= n; j++) {
    if (g[j].size() == 1) {
      leafs++;
    } else {
      root = j;
    }
  }
  leafs >>= 1;
  dfs(root, 0);
  printf("%d\n", min(d[0][root][leafs], d[1][root][leafs]));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  srand(1337);
  solve();
  return 0;
}
