#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
vector<int> G[N];
int leaf = 0;
int sz[N], dp[N][N / 2][2];
int t[N][2];
inline void ck(int &x, int v) {
  if (x > v) x = v;
}
void dfs(int u, int fa) {
  for (int i = 0; i <= leaf; ++i) {
    dp[u][i][0] = dp[u][i][1] = 0x3f3f3f3f;
  }
  if ((int)G[u].size() == 1) {
    sz[u] = 1;
    dp[u][0][0] = dp[u][1][1] = 0;
    return;
  }
  sz[u] = 0;
  dp[u][0][0] = dp[u][0][1] = 0;
  for (auto v : G[u]) {
    if (v == fa) continue;
    dfs(v, u);
    int x = min(leaf, sz[u]);
    int y = min(leaf, sz[v]);
    for (int i = 0; i <= leaf; ++i) {
      t[i][0] = t[i][1] = 0x3f3f3f3f;
    }
    for (int i = 0; i <= x; ++i) {
      for (int j = 0; j <= y; ++j) {
        if (i + j > leaf) break;
        ck(t[i + j][0], dp[u][i][0] + min(dp[v][j][0], dp[v][j][1] + 1));
        ck(t[i + j][1], dp[u][i][1] + min(dp[v][j][1], dp[v][j][0] + 1));
      }
    }
    for (int i = 0; i <= leaf; ++i) {
      dp[u][i][0] = t[i][0];
      dp[u][i][1] = t[i][1];
    }
    sz[u] += sz[v];
  }
}
int main() {
  int n;
  scanf("%d", &n);
  if (n == 2) {
    puts("1");
    return 0;
  }
  for (int x, y, i = 1; i < n; ++i) {
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  int rt;
  for (int i = 1; i <= n; ++i) {
    int sz = G[i].size();
    sz > 1 ? rt = i : ++leaf;
  }
  leaf >>= 1;
  dfs(rt, -1);
  printf("%d\n", min(dp[rt][leaf][0], dp[rt][leaf][1]));
  return 0;
}
