#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
vector<int> ladj[N];
int leaves[N], dp[N][N];
void dfs(int u, int p) {
  int n = (int)ladj[u].size();
  leaves[u] = n == 1 ? 1 : 0;
  for (int i = 0; i < N; i++) dp[u][i] = N;
  dp[u][0] = 0;
  for (int i = 0; i < n; i++) {
    int v = ladj[u][i];
    if (v == p) continue;
    dfs(v, u);
    for (int j = leaves[u]; j >= 0; j--)
      for (int w = 0; w <= leaves[v]; w++)
        dp[u][j + w] = min(dp[u][j + w], dp[v][w] + dp[u][j]);
    leaves[u] += leaves[v];
  }
  for (int i = 0; i <= leaves[u]; i++)
    dp[u][leaves[u] - i] = min(dp[u][leaves[u] - i], dp[u][i] + 1);
}
bool solve(int testNumber) {
  int n;
  if (scanf("%d", &n) == EOF) return false;
  for (int i = 0; i < N; i++) ladj[i].clear();
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    ladj[u - 1].push_back(v - 1);
    ladj[v - 1].push_back(u - 1);
  }
  if (n == 2)
    puts("1");
  else
    for (int i = 0;; i++) {
      if ((int)ladj[i].size() > 1) {
        dfs(i, -1);
        printf("%d\n", dp[i][leaves[i] / 2]);
        break;
      }
    }
  return true;
}
int main() {
  for (int i = 1; solve(i); i++)
    ;
  return 0;
}
