#include <bits/stdc++.h>
using namespace std;
vector<int> tu[5001];
int dp[5001][5001][2];
int inf = 0x3f3f3f3f;
int dfs(int xz, int die) {
  dp[xz][0][0] = dp[xz][0][1] = 0;
  int yigong = 0, biaoji = 1;
  for (int a = 0; a < tu[xz].size(); a++) {
    if (tu[xz][a] == die) continue;
    biaoji = 0;
    int xzdian = dfs(tu[xz][a], xz);
    yigong += xzdian;
    for (int b = yigong; b >= 0; b--) {
      int da1 = inf, da0 = inf;
      for (int c = 0; c <= xzdian; c++) {
        da0 = min(da0, min(dp[xz][b - c][0] + dp[tu[xz][a]][c][0],
                           dp[xz][b - c][0] + 1 + dp[tu[xz][a]][c][1]));
        da1 = min(da1, min(dp[xz][b - c][1] + dp[tu[xz][a]][c][1],
                           dp[xz][b - c][1] + 1 + dp[tu[xz][a]][c][0]));
      }
      dp[xz][b][0] = da0;
      dp[xz][b][1] = da1;
    }
  }
  if (biaoji) {
    dp[xz][1][1] = 0;
    dp[xz][0][1] = inf;
  }
  return yigong + biaoji;
}
int main() {
  int n;
  cin >> n;
  if (n == 2) {
    cout << 1;
    return 0;
  }
  memset(dp, 0x3f, sizeof(dp));
  for (int a = 1; a <= n - 1; a++) {
    int q, w;
    cin >> q >> w;
    tu[q].push_back(w);
    tu[w].push_back(q);
  }
  int jc = 0;
  int y = 0;
  int yu = 0;
  for (int a = 1; a <= n; a++) {
    if (tu[a].size() > 1) {
      if (!jc) dfs(a, 0), y = a, jc++;
    } else
      yu++;
  }
  cout << min(dp[y][yu / 2][0], dp[y][yu / 2][1]);
}
