#include <bits/stdc++.h>
using namespace std;
const int maxn = 5010;
const double eps = 1e-6;
const double pi = acos(-1.0);
int n, m;
int dp[maxn][maxn], Root, Temp[maxn];
int fst[maxn], nxt[maxn * 2], to[maxn * 2], tot, u, v, In[maxn], Leaf[maxn];
void Add(int u, int v) {
  to[tot] = v;
  nxt[tot] = fst[u];
  fst[u] = tot++;
}
void dfs(int root, int fa) {
  bool IsLeaf = true;
  Leaf[root] = 0;
  for (int i = fst[root]; i + 1; i = nxt[i]) {
    int s = to[i];
    if (s != fa) {
      dfs(s, root);
      Leaf[root] += Leaf[s];
      IsLeaf = false;
    }
  }
  if (IsLeaf) {
    Leaf[root]++;
  }
}
int minn(int x, int y) { return x < y ? x : y; }
void GetAns(int root, int fa) {
  int sum = 0;
  for (int i = fst[root]; i + 1; i = nxt[i]) {
    int s = to[i];
    if (s != fa) {
      GetAns(s, root);
      for (int j = Leaf[s] + sum; j >= 0; j--)
        for (int k = 0; k <= minn(Leaf[s], j); k++)
          dp[root][j] = minn(dp[root][j], dp[root][j - k] + dp[s][k]);
      sum += Leaf[s];
    }
  }
  dp[root][Leaf[root]] = 1;
  for (int i = 0; i <= sum; i++) Temp[i] = dp[root][i];
  for (int i = 0; i <= sum; i++)
    dp[root][i] = minn(dp[root][i], Temp[sum - i] + (root != Root));
}
int main() {
  while (~scanf("%d", &n)) {
    memset(fst, -1, sizeof fst);
    memset(In, 0, sizeof In);
    tot = 0;
    for (int i = 1; i < n; i++) {
      scanf("%d %d", &u, &v);
      Add(u, v);
      Add(v, u);
      In[u]++;
      In[v]++;
    }
    int root = -1;
    for (int i = 1; i <= n; i++)
      if (In[i] > 1) {
        root = i;
        break;
      }
    if (root == -1) {
      printf("1\n");
      return 0;
    }
    Root = root;
    dfs(root, -1);
    memset(dp, 0x3f3f3f3f, sizeof dp);
    for (int i = 1; i <= n; i++) {
      dp[i][0] = 0;
    }
    GetAns(root, -1);
    printf("%d\n", dp[root][Leaf[root] / 2]);
  }
}
