#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> g[5013];
int s[5013];
int dp[5013][5013];
void solve(int x, int p = 0) {
  s[x] = (g[x].size() == 1);
  for (int i : g[x]) {
    if (i != p) {
      solve(i, x);
      s[x] += s[i];
    }
  }
  for (int i = 0; i <= n; i++) dp[x][i] = 1e9;
  dp[x][0] = 0;
  for (int i : g[x])
    if (i != p) {
      for (int j = s[x]; j >= 0; j--)
        for (int u = min(j, s[i]); u >= 0; u--) {
          dp[x][j] = min(dp[x][j], dp[i][u] + dp[x][j - u]);
        }
    }
  for (int i = 0; i <= s[x]; i++)
    dp[x][s[x] - i] = min(dp[x][s[x] - i], 1 + dp[x][i]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int root = 1;
  while (g[root].size() == 1) root++;
  solve(root);
  printf("%d\n", n == 2 ? 1 : dp[root][s[root] / 2]);
  return 0;
}
