#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int dp[N][N][2], sz[N], n;
vector<int> al[N];
int leaf[N];
void dfsl(int u, int p = -1) {
  if (al[u].size() == 1) {
    leaf[u] = 1;
    return;
  }
  for (int i = 0; i < al[u].size(); ++i) {
    int v = al[u][i];
    if (v == p) continue;
    dfsl(v, u);
    leaf[u] += leaf[v];
  }
}
void dfs(int v, int p = -1) {
  if (al[v].size() == 1) {
    dp[v][0][1] = 0;
    dp[v][1][0] = 0;
    return;
  }
  for (int i = 0; i < 2; ++i) dp[v][(int)al[v].size() == 1 && i == 0][i] = 0;
  int mx = 0;
  for (int i = 0; i < al[v].size(); ++i) {
    int u = al[v][i];
    if (u != p) {
      dfs(u, v);
      mx += leaf[u];
      for (int fp = mx; ~fp; --fp) {
        for (int f = 0; f < 2; ++f) {
          if (dp[v][fp][f] < n) {
            int was = dp[v][fp][f];
            dp[v][fp][f] = 1000000000;
            for (int sp = 0; sp <= leaf[u]; ++sp) {
              for (int s = 0; s < 2; ++s) {
                dp[v][fp + sp][f] =
                    ((dp[v][fp + sp][f]) < (dp[u][sp][s] + was + (f != s))
                         ? (dp[v][fp + sp][f])
                         : (dp[u][sp][s] + was + (f != s)));
              }
            }
          }
        }
      }
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  memset(dp, 63, sizeof dp);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    al[u].push_back(v);
    al[v].push_back(u);
  }
  int leaf_cnt = 0;
  for (int i = 0; i < n; ++i)
    if ((int)al[i].size() == 1) leaf_cnt++;
  memset(leaf, 0, sizeof(leaf));
  int root = 0;
  while (al[root].size() == 1) root++;
  dfsl(root);
  dfs(root);
  cout << ((dp[root][leaf_cnt >> 1][0]) < (dp[root][leaf_cnt >> 1][1])
               ? (dp[root][leaf_cnt >> 1][0])
               : (dp[root][leaf_cnt >> 1][1]))
       << endl;
  return 0;
}
