#include <bits/stdc++.h>
const long long MOD = 1000000007;
using namespace std;
int n;
int dp[(5000 + 10)][2][(5000 + 10)], sz_leaf[(5000 + 10)], c[2][(5000 + 10)];
vector<int> tree[(5000 + 10)];
void dfs(int u, int fa) {
  if (sz_leaf[u] == 1)
    dp[u][0][1] = dp[u][1][0] = 0;
  else
    dp[u][0][0] = dp[u][1][0] = 0;
  int v;
  for (int i = 0; i < tree[u].size(); ++i) {
    v = tree[u][i];
    if (v == fa) continue;
    dfs(v, u);
    for (int i = 0; i <= n; ++i) c[1][i] = c[0][i] = 0x3f3f3f3f;
    for (int j = 0; j <= sz_leaf[u]; ++j)
      for (int k = 0; k <= sz_leaf[v]; ++k) {
        c[1][j + k] = min(c[1][j + k], dp[u][1][j] + dp[v][1][k]);
        c[1][j + k] = min(c[1][j + k], dp[u][1][j] + dp[v][0][k] + 1);
        c[0][j + k] = min(c[0][j + k], dp[u][0][j] + dp[v][0][k]);
        c[0][j + k] = min(c[0][j + k], dp[u][0][j] + dp[v][1][k] + 1);
      }
    sz_leaf[u] += sz_leaf[v];
    for (int j = 0; j <= sz_leaf[u] + sz_leaf[v]; ++j) {
      dp[u][1][j] = c[1][j];
      dp[u][0][j] = c[0][j];
    }
  }
}
int main() {
  scanf("%d", &n);
  int u, v;
  for (int i = 1; i < n; ++i) {
    scanf("%d %d", &u, &v);
    tree[u].push_back(v);
    tree[v].push_back(u);
  }
  int root = 1;
  for (int i = 1; i <= n; ++i) {
    if (tree[i].size() == 1)
      sz_leaf[i] = 1;
    else {
      root = i;
      sz_leaf[i] = 0;
    }
  }
  if (root == 1 && tree[1].size() == 1) {
    printf("%d\n", (1));
    return 0;
  }
  memset(dp, (0x3f3f3f3f), sizeof(dp));
  dfs(root, -1);
  printf("%d\n",
         (min(dp[root][1][sz_leaf[root] / 2], dp[root][0][sz_leaf[root] / 2])));
  return 0;
}
