#include <bits/stdc++.h>
using namespace std;
template <class temp>
inline void Rd(temp &p) {
  p = 0;
  char c;
  while (c = getchar(), c < 48)
    ;
  do p = p * 10 + (c & 15);
  while (c = getchar(), c > 47);
}
template <class temp>
inline void Min(temp &a, temp b) {
  if (a > b) a = b;
}
int n, rt = 1, cnt = 0;
bool leaf[5005];
vector<int> G[5005];
int sz[5005];
int dp[5005][5005];
int res[5005];
void Dp(int u, int fa) {
  dp[u][0] = 0;
  if (leaf[u])
    sz[u] = 1;
  else
    sz[u] = 0;
  for (int j = 0; j < G[u].size(); j++) {
    int v = G[u][j];
    if (v == fa) continue;
    Dp(v, u);
    for (int i = min(cnt, sz[u] + sz[v]); i > 0; i--)
      for (int k = 0; k <= sz[v] && i - k >= 0; k++)
        Min(dp[u][i], dp[u][i - k] + dp[v][k]);
    sz[u] += sz[v];
  }
  for (int i = max(0, sz[u] - cnt); i <= min(cnt, sz[u]); i++)
    Min(dp[u][i], dp[u][sz[u] - i] + 1);
}
int main() {
  Rd(n);
  for (int i = 1, u, v; i < n; i++) {
    Rd(u), Rd(v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++)
    if (G[i].size() == 1) leaf[i] = true, ++cnt;
  cnt >>= 1;
  memset(dp, 0x3f, sizeof(dp));
  Dp(rt, 0);
  printf("%d\n", dp[rt][cnt]);
}
