#include <bits/stdc++.h>
using namespace std;
vector<int> G[5010];
int dp[5010][5010][2];
int sz[5010];
int n;
int dfs(int u, int fa) {
  memset(dp[u], 0x3f, sizeof(dp[u]));
  sz[u] = 0;
  int ch = 0;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa) continue;
    ch++;
    if (ch == 1) dp[u][0][1] = dp[u][0][0] = 0;
    sz[u] += dfs(v, u);
    for (int j = sz[u]; j >= 0; j--) {
      for (int k = 0; k <= min(j, sz[v]); k++) {
        if (k == 0) {
          dp[u][j][0] = min(dp[u][j - k][0] + dp[v][k][1] + 1,
                            dp[u][j - k][0] + dp[v][k][0]);
          dp[u][j][1] = min(dp[u][j - k][1] + dp[v][k][0] + 1,
                            dp[u][j - k][1] + dp[v][k][1]);
        } else {
          dp[u][j][0] = min(dp[u][j][0], min(dp[u][j - k][0] + dp[v][k][1] + 1,
                                             dp[u][j - k][0] + dp[v][k][0]));
          dp[u][j][1] = min(dp[u][j][1], min(dp[u][j - k][1] + dp[v][k][0] + 1,
                                             dp[u][j - k][1] + dp[v][k][1]));
        }
      }
    }
  }
  if (ch == 0) {
    dp[u][0][0] = dp[u][1][1] = 0;
    sz[u] = 1;
  }
  return sz[u];
}
int main() {
  scanf("%d", &n);
  int root;
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  int allnum = 0;
  for (int i = 1; i <= n; i++) {
    if (G[i].size() >= 2) {
      root = i;
    } else {
      allnum++;
    }
  }
  dfs(root, -1);
  printf("%d\n", min(dp[root][allnum / 2][0], dp[root][allnum / 2][1]));
  return 0;
}
