#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int N = 5005;
const int INF = INT_MAX / 10;
int dp[N][N][2], sz[N], limit;
vector<int> edges[N];
int dfs(int u, int par) {
  int children = 0, maxCnt = 0, r = -1;
  for (int i = 0; i < edges[u].size(); ++i) {
    int v = edges[u][i];
    if (v != par) {
      if (r == -1) r = v;
      children++;
      sz[u] += dfs(v, u);
    }
  }
  if (children == 0) {
    dp[u][1][1] = dp[u][0][0] = 0;
    return (sz[u] = 1);
  }
  maxCnt = sz[r];
  for (int i = 0; i <= maxCnt; ++i) {
    dp[u][i][0] = min(dp[r][i][0], dp[r][i][1] + 1);
    dp[u][i][1] = min(dp[r][i][1], dp[r][i][0] + 1);
  }
  int fdp[N];
  for (int j = 0; j < edges[u].size(); ++j) {
    int v = edges[u][j];
    if (v != par && v != r) {
      maxCnt += sz[v];
      for (int pCol = 0; pCol < 2; ++pCol) {
        for (int k = 0; k <= min(maxCnt, limit); ++k) fdp[k] = INF;
        for (int cnt = 0; cnt <= min(maxCnt, limit); ++cnt) {
          for (int i = 0; i <= min(cnt, sz[v]); ++i) {
            for (int cCol = 0; cCol < 2; ++cCol) {
              fdp[cnt] = min(fdp[cnt], dp[u][cnt - i][pCol] + dp[v][i][cCol] +
                                           (cCol != pCol));
            }
          }
        }
        for (int k = 0; k <= min(maxCnt, limit); ++k) dp[u][k][pCol] = fdp[k];
      }
    }
  }
  return sz[u];
}
int main() {
  int n, x, y;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d %d", &x, &y);
    edges[x].push_back(y);
    edges[y].push_back(x);
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < 2; ++k) {
        dp[i][j][k] = INF;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (edges[i].size() == 1) limit++;
  }
  limit >>= 1;
  for (int i = 1; i <= n; ++i) {
    if (edges[i].size() > 1) {
      dfs(i, 0);
      printf("%d\n", min(dp[i][sz[i] / 2][0], dp[i][sz[i] / 2][1]));
      break;
    }
  }
  return 0;
}
