#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ '0');
    ch = getchar();
  }
  return x * f;
}
vector<int> G[5005];
inline void AddEdge(int u, int v) { G[u].push_back(v); }
int dp[5005][5005][2];
int sz[5005], leave;
void dfs(int u, int father) {
  for (register int i = 0; i < G[u].size(); ++i) {
    int v = G[u][i];
    if (v != father) {
      dfs(v, u);
      sz[u] += sz[v];
    }
  }
  if (!sz[u]) {
    dp[u][1][1] = dp[u][0][0] = 0;
    leave++;
    sz[u] = 1;
    return;
  } else {
    dp[u][0][0] = dp[u][0][1] = 0;
  }
  for (register int i = 0; i < G[u].size(); ++i) {
    int v = G[u][i];
    if (v != father) {
      for (register int j = sz[u]; j >= 0; --j) {
        int a = 0x3f3f3f3f, b = 0x3f3f3f3f;
        for (register int k = 0; k <= min(sz[v], j); ++k) {
          a = min(a, dp[u][j - k][0] + min(dp[v][k][0], dp[v][k][1] + 1));
          b = min(b, dp[u][j - k][1] + min(dp[v][k][1], dp[v][k][0] + 1));
        }
        dp[u][j][0] = a, dp[u][j][1] = b;
      }
    }
  }
}
int main() {
  memset(dp, 0x3f, sizeof(dp));
  int n = read();
  for (register int i = 1; i < n; ++i) {
    int u = read(), v = read();
    AddEdge(u, v), AddEdge(v, u);
  }
  for (register int i = 1; i <= n; ++i) {
    if (G[i].size() > 1) {
      dfs(i, 0);
      printf("%d\n", min(dp[i][leave / 2][0], dp[i][leave / 2][1]));
      return 0;
    }
  }
}
