#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000 + 5, inf = 1e5 + 7;
int n, root, leaf, s[maxn], dp[maxn][maxn], dp2[maxn];
vector<int> adj[maxn];
void dfs(int v = root, int p = 0) {
  dp[v][0] = 0;
  for (auto u : adj[v])
    if (u != p) {
      dfs(u, v);
      for (int i = 0; i <= s[v]; i++)
        for (int j = 0; j <= s[u]; j++)
          dp2[i + j] = min({dp2[i + j], dp[v][i] + dp[u][j],
                            dp[v][i] + dp[u][s[u] - j] + 1});
      for (int i = 0; i < maxn; i++) dp[v][i] = dp2[i], dp2[i] = inf;
      s[v] += s[u];
    }
  if (adj[v].size() == 1 && v != root) {
    dp[v][0] = inf, dp[v][1] = 0;
    s[v] = 1;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(dp, 1, maxn * maxn);
  memset(dp2, 1, maxn);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (adj[i].size() > 1)
      root = i;
    else
      leaf++;
  }
  if (!root) return cout << 0 << '\n', 0;
  dfs();
  cout << dp[root][leaf / 2] << '\n';
}
