#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
const int INF = 0x3f3f3f3f;
template <typename T>
inline void read(T &AKNOI) {
  T x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  AKNOI = flag * x;
}
template <typename T>
inline void cmin(T &x, T y) {
  if (x > y) x = y;
}
int n;
int siz[MAXN], dp[MAXN][MAXN][2], tmp[MAXN][2];
vector<int> g[MAXN];
void DFS(int u, int fa) {
  if (g[u].size() == 1) {
    siz[u] = 1;
    dp[u][0][0] = dp[u][1][1] = 0;
    return;
  }
  dp[u][0][0] = dp[u][0][1] = 0;
  for (auto v : g[u]) {
    if (v == fa) continue;
    DFS(v, u);
    for (int i = 0; i <= siz[u]; ++i) {
      for (int j = 0; j <= siz[v]; ++j) {
        cmin(tmp[i + j][0], dp[u][i][0] + dp[v][j][0]);
        cmin(tmp[i + j][0], dp[u][i][0] + dp[v][j][1] + 1);
        cmin(tmp[i + j][1], dp[u][i][1] + dp[v][j][1]);
        cmin(tmp[i + j][1], dp[u][i][1] + dp[v][j][0] + 1);
      }
    }
    siz[u] += siz[v];
    for (int i = 0; i <= siz[u]; ++i) {
      dp[u][i][0] = tmp[i][0];
      dp[u][i][1] = tmp[i][1];
      tmp[i][0] = tmp[i][1] = INF;
    }
  }
}
void init() {
  read(n);
  for (int i = 1, u, v; i < n; ++i) {
    read(u);
    read(v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
}
void solve() {
  if (n == 2) {
    printf("1\n");
    return;
  }
  int rt = 1;
  while (g[rt].size() == 1) {
    ++rt;
  }
  memset(dp, 0x3f, sizeof(dp));
  memset(tmp, 0x3f, sizeof(tmp));
  DFS(rt, 0);
  int half = siz[rt] / 2;
  printf("%d\n", min(dp[rt][half][0], dp[rt][half][1]));
}
int main() {
  init();
  solve();
  return 0;
}
