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