#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n, dcnt;
vector<int> adj[5005];
int sz[5005];
int dp[5005][2505][2];
void getsz(int cur, int p) {
  sz[cur] = 1;
  for (int i = 0; i < adj[cur].size(); ++i) {
    int nxt = adj[cur][i];
    if (nxt == p) continue;
    getsz(nxt, cur);
    sz[cur] += sz[nxt];
  }
}
void dfs(int cur, int p) {
  vector<vector<vector<int> > > tdp(
      2, vector<vector<int> >(sz[cur] + 1, vector<int>(2, INF)));
  if (adj[cur].size() > 1) {
    tdp[0][0][0] = tdp[0][0][1] = 0;
  } else {
    tdp[0][1][0] = tdp[0][0][1] = 0;
  }
  for (int i = 0; i < adj[cur].size(); ++i) {
    int nxt = adj[cur][i];
    if (nxt == p) continue;
    dfs(nxt, cur);
    for (int j = 0; j <= sz[cur]; ++j) {
      for (int k = 0; k <= sz[nxt]; ++k) {
        if (j + k > sz[cur]) break;
        for (int a = 0; a < 2; ++a) {
          for (int b = 0; b < 2; ++b) {
            tdp[1][j + k][a] =
                min(tdp[1][j + k][a], tdp[0][j][a] + dp[nxt][k][b] + (a != b));
          }
        }
      }
    }
    swap(tdp[0], tdp[1]);
    tdp[1] = vector<vector<int> >(sz[cur] + 1, vector<int>(2, INF));
  }
  for (int i = 0; i <= sz[cur]; ++i) {
    dp[cur][i][0] = tdp[0][i][0];
    dp[cur][i][1] = tdp[0][i][1];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  if (n == 2) {
    puts("1");
    return 0;
  }
  int start = 0;
  for (int i = 1; i <= n; ++i) {
    if (adj[i].size() >= 2) {
      start = i;
    }
    if (adj[i].size() == 1) ++dcnt;
  }
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= dcnt / 2; ++j) dp[i][j][0] = dp[i][j][1] = INF;
  getsz(start, 0);
  dfs(start, 0);
  int ans = min(dp[start][dcnt / 2][0], dp[start][dcnt / 2][1]);
  printf("%d\n", ans);
}
