#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
const int maxn = 5e3 + 10, maxm = 5e2 + 10, lg = 18, mod = 1e9 + 7, inf = 1e18;
int n, dp[maxn][maxn], fl[maxn];
vector<int> g[maxn];
void dfs(int v = 1, int p = 0) {
  dp[v][fl[v] = ((int)(g[v].size()) == 1)] = 0;
  for (auto u : g[v])
    if (u != p) {
      dfs(u, v);
      for (int i = (fl[v] += fl[u]), tmp = inf; ~i; dp[v][i--] = tmp, tmp = inf)
        for (int j = min(i, fl[u]); ~j; j--)
          tmp = min(tmp, dp[v][i - j] + min(dp[u][j], dp[u][fl[u] - j] + 1));
    }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  memset(dp, 69, sizeof(dp));
  cin >> n;
  for (int i = 1; i < n; i++) {
    int v, u;
    cin >> v >> u;
    g[v].push_back(u), g[u].push_back(v);
  }
  dfs();
  cout << dp[1][fl[1] / 2];
  return 0;
}
