#include <bits/stdc++.h>
using namespace std;
const int N = 5050;
const int inf = 0x37373737;
int L[N], R[N], size[N], tot, n, i, a, b, cnt, j, k;
int d[N], root;
int dp[N][N];
vector<pair<int, int> > vec[N];
vector<int> e[N];
void dfs(int x, int fa) {
  int i, j, k;
  if (e[x].size() == 1) size[x] = 1;
  for (i = 0; i < e[x].size(); i++)
    if (e[x][i] != fa) {
      dfs(e[x][i], x);
      for (j = size[x]; j >= 0; j--)
        for (k = 0; k <= size[e[x][i]]; k++)
          dp[x][j + k] = min(dp[x][j + k], dp[x][j] + dp[e[x][i]][k]);
      size[x] += size[e[x][i]];
    }
  for (i = 0; i <= size[x]; i++)
    dp[x][i] = min(dp[x][i], dp[x][size[x] - i] + 1);
}
int main() {
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    e[a].push_back(b);
    e[b].push_back(a);
    d[a]++;
    d[b]++;
  }
  if (n == 2) {
    printf("1");
    return 0;
  }
  for (i = 1; i <= n; i++)
    if (d[i] != 1) break;
  root = i;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) dp[i][j] = inf;
  dfs(root, 0);
  printf("%d\n", dp[root][size[root] / 2]);
}
