#include <bits/stdc++.h>
using namespace std;
const int max_n = 5020, inf = 1000 * 1000;
vector<int> v[max_n];
int dp[max_n][2][max_n], lf[max_n];
void dfs(int u, int p) {
  for (int i = 0; i < max_n - 10; i++) {
    dp[u][0][i] = inf;
    dp[u][1][i] = inf;
  }
  if (v[u].size() == 1) {
    lf[u]++;
    dp[u][0][1] = 0;
    dp[u][1][0] = 0;
  }
  bool check = false;
  for (auto i : v[u])
    if (i != p) {
      dfs(i, u);
      lf[u] += lf[i];
      for (int x = lf[u]; x >= 0; x--) {
        int a = dp[i][0][0], b = dp[i][1][0];
        if (check) {
          dp[u][0][x] += min(a, b + 1);
          dp[u][1][x] += min(a + 1, b);
        } else {
          dp[u][0][x] = min(dp[i][0][x], dp[i][1][x] + 1);
          dp[u][1][x] = min(dp[i][0][x] + 1, dp[i][1][x]);
        }
        for (int y = 1; y <= min(x, lf[i]); y++) {
          dp[u][0][lf[u]] = 0;
          dp[u][1][0] = 0;
          a = dp[i][0][y];
          b = dp[i][1][y];
          dp[u][0][x] = min(dp[u][0][x], a + dp[u][0][x - y]);
          dp[u][0][x] = min(dp[u][0][x], b + dp[u][0][x - y] + 1);
          dp[u][1][x] = min(dp[u][1][x], a + dp[u][1][x - y] + 1);
          dp[u][1][x] = min(dp[u][1][x], b + dp[u][1][x - y]);
        }
      }
      dp[u][0][lf[u]] = 0;
      dp[u][1][0] = 0;
      check = true;
    }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  if (n == 2) {
    cout << 1 << endl;
    return 0;
  }
  int id = -1;
  for (int i = 0; i < n; i++)
    if (v[i].size() > 1) id = i;
  dfs(id, -1);
  cout << min(dp[id][0][lf[id] / 2], dp[id][1][lf[id] / 2]) << endl;
}
