#include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
const int INF = (int)1.01e9;
const long double EPS = 1e-9;
void precalc() {}
const int maxn = 5000 + 10;
int n;
vector<vector<int> > es;
bool read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  es = vector<vector<int> >(n);
  for (int i = 0; i < n - 1; ++i) {
    int s, t;
    scanf("%d%d", &s, &t);
    --s, --t;
    es[s].push_back(t), es[t].push_back(s);
  }
  return 1;
}
int used[maxn];
int cnts[maxn];
int dp[maxn][maxn];
int tmp[maxn];
void dfs(int v) {
  used[v] = 1;
  cnts[v] = 0;
  dp[v][0] = 0;
  if (((int)(es[v]).size()) == 1) {
    ++cnts[v];
    dp[v][0] = INF;
    dp[v][1] = 0;
  }
  for (int it = 0; it < ((int)(es[v]).size()); ++it) {
    int u = es[v][it];
    if (used[u]) {
      continue;
    }
    dfs(u);
    int cnt = cnts[v];
    for (int x = 0; x <= cnt; ++x) {
      tmp[x] = dp[v][x];
    }
    cnts[v] += cnts[u];
    for (int x = 0; x <= cnts[v]; ++x) {
      dp[v][x] = INF;
    }
    for (int xt = 0; xt <= cnt; ++xt) {
      for (int xu = 0; xu <= cnts[u]; ++xu) {
        int &cur = dp[v][xt + xu];
        cur = min(cur, tmp[xt] + min(dp[u][xu], 1 + dp[u][cnts[u] - xu]));
      }
    }
  }
}
void solve() {
  for (int i = 0; i < n; ++i) {
    used[i] = 0;
  }
  dfs(0);
  printf("%d\n", dp[0][cnts[0] / 2]);
}
int main() {
  srand(rdtsc());
  precalc();
  while (1) {
    if (!read()) {
      break;
    }
    solve();
  }
  return 0;
}
