#include <bits/stdc++.h>
using namespace std;
const int N = 5000 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-8;
const double PI = acos(-1);
template <class T, class S>
inline void add(T& a, S b) {
  a += b;
  if (a >= mod) a -= mod;
}
template <class T, class S>
inline void sub(T& a, S b) {
  a -= b;
  if (a < 0) a += mod;
}
template <class T, class S>
inline bool chkmax(T& a, S b) {
  return a < b ? a = b, true : false;
}
template <class T, class S>
inline bool chkmin(T& a, S b) {
  return a > b ? a = b, true : false;
}
int n, leaf;
int dp[N][2][N];
int tmp[2][N];
int sum[N];
bool isleaf[N];
vector<int> G[N];
void dfs(int u, int fa) {
  if (isleaf[u]) {
    dp[u][0][1] = dp[u][1][0] = 0;
    sum[u] = 1;
    return;
  }
  dp[u][1][0] = dp[u][0][0] = 0;
  for (auto& v : G[u]) {
    if (v == fa) continue;
    dfs(v, u);
    memset(tmp, inf, sizeof(tmp));
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        for (int c1 = 0; c1 <= sum[u]; c1++) {
          for (int c2 = 0; c2 <= sum[v]; c2++) {
            chkmin(tmp[i][c1 + c2], dp[u][i][c1] + dp[v][j][c2] + (i != j));
          }
        }
      }
    }
    sum[u] += sum[v];
    memcpy(dp[u], tmp, sizeof(dp[u]));
  }
}
int main() {
  memset(dp, inf, sizeof(dp));
  scanf("%d", &n);
  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);
  }
  if (n == 2) return puts("1"), 0;
  int root = -1;
  for (int i = 1; i <= n; i++) {
    if (((int)G[i].size()) != 1)
      root = i;
    else
      leaf++, isleaf[i] = true;
  }
  dfs(root, 0);
  printf("%d\n", min(dp[root][0][leaf >> 1], dp[root][1][leaf >> 1]));
  return 0;
}
