#include <bits/stdc++.h>
const int N = 5000 + 1;
const short INF = 6666;
short dp[N][N][2];
int n;
std::vector<int> edges[N];
short tmp[N][2];
int sz[N];
inline void update(short &a, short b) {
  if (a > b) a = b;
}
void dfs(int u, int fa) {
  sz[u] = 0;
  if (edges[u].size() == 1) {
    dp[u][0][1] = INF;
    dp[u][1][0] = INF;
    sz[u] = 1;
    return;
  }
  for (int v : edges[u]) {
    if (v == fa) continue;
    dfs(v, u);
    for (int i = 0; i <= sz[u] + sz[v]; ++i)
      for (int j = 0; j < 2; ++j) tmp[i][j] = INF;
    for (int i = 0; i <= sz[u]; ++i) {
      for (int j = 0; j <= sz[v]; ++j) {
        for (int a = 0; a < 2; ++a) {
          for (int b = 0; b < 2; ++b) {
            update(tmp[i + j][a], dp[u][i][a] + dp[v][j][b] + short(a != b));
          }
        }
      }
    }
    sz[u] += sz[v];
    for (int i = 0; i <= sz[u]; ++i)
      for (int j = 0; j < 2; ++j) dp[u][i][j] = tmp[i][j];
  }
}
int work() {
  if (n == 2) return 1;
  for (int i = 0; i < n; ++i) {
    if (edges[i].size() > 1) {
      dfs(i, -1);
      return std::min(dp[i][sz[i] / 2][0], dp[i][sz[i] / 2][1]);
    }
  }
  return -1;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  printf("%d\n", work());
}
