#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> g[1 << 15];
int leaves, root;
int dp[5005][5005][2];
vector<int> sons[1 << 15];
int subsize[5005];
int knap[5005][3], nknap[5005][3];
int used[5005];
void solve(int v) {
  if (g[v].size() == 1) subsize[v] = 1;
  used[v] = 1;
  vector<int> sons;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (used[to]) continue;
    sons.push_back(to);
    solve(to);
    subsize[v] += subsize[to];
  }
  for (int i = 0; i <= subsize[v]; i++) dp[v][i][0] = dp[v][i][1] = 1e9;
  if (sons.size() == 0) {
    dp[v][0][0] = dp[v][1][1] = 0;
    return;
  }
  int ttl = 0;
  for (int i = 0; i <= subsize[v]; i++)
    knap[i][0] = knap[i][1] = nknap[i][0] = nknap[i][1] = 1e9;
  knap[0][0] = knap[0][1] = 0;
  for (int i = 0; i < sons.size(); i++) {
    for (int j = 0; j <= ttl + subsize[sons[i]]; j++)
      nknap[j][0] = 1e9, nknap[j][1] = 1e9;
    int id = sons[i];
    for (int j = ttl; j >= 0; --j)
      for (int q = 0; q <= subsize[id]; q++)
        for (int val1 = 0; val1 <= 1; val1++)
          for (int val2 = 0; val2 <= 1; val2++)
            nknap[j + q][val1] =
                min(nknap[j + q][val1],
                    knap[j][val1] + dp[id][q][val2] + (val1 != val2));
    for (int j = 0; j <= ttl + subsize[id]; j++)
      knap[j][0] = nknap[j][0], knap[j][1] = nknap[j][1];
    ttl += subsize[id];
  }
  for (int i = 0; i <= subsize[v]; i++)
    dp[v][i][0] = knap[i][0], dp[v][i][1] = knap[i][1];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  if (n == 2) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (g[i].size() == 1) ++leaves;
  root = 1;
  while (g[root].size() == 1) ++root;
  solve(root);
  cout << min(dp[root][leaves / 2][0], dp[root][leaves / 2][1]) << endl;
  return 0;
}
