#include <bits/stdc++.h>
using namespace std;
const int maxn = 5E3 + 5;
int n, deg[maxn];
int size, head[maxn];
int sum[maxn], f[maxn][maxn][2];
struct edge {
  int to, next;
} E[maxn * 2];
inline void add(int u, int v) {
  E[++size].to = v;
  E[size].next = head[u];
  head[u] = size;
}
int tmp0[maxn], tmp1[maxn];
inline void chmin(int& x, int y) { x = min(x, y); }
void dfs(int u, int F) {
  for (int i = 0; i <= n; ++i) f[u][i][0] = f[u][i][1] = n + 1;
  if (deg[u] == 1) {
    f[u][0][0] = f[u][1][1] = 0;
    sum[u] = 1;
    return;
  }
  f[u][0][0] = f[u][0][1] = 0;
  for (int e = head[u]; e; e = E[e].next) {
    int v = E[e].to;
    if (v == F) continue;
    dfs(v, u);
    for (int i = 0; i <= sum[u] + sum[v]; ++i) tmp0[i] = tmp1[i] = n + 1;
    for (int i = 0; i <= sum[u]; ++i)
      for (int j = 0; j <= sum[v]; ++j) {
        chmin(tmp0[i + j], f[u][i][0] + f[v][j][0]);
        chmin(tmp0[i + j], f[u][i][0] + f[v][j][1] + 1);
        chmin(tmp1[i + j], f[u][i][1] + f[v][j][1]);
        chmin(tmp1[i + j], f[u][i][1] + f[v][j][0] + 1);
      }
    sum[u] += sum[v];
    for (int i = 0; i <= sum[u]; ++i)
      f[u][i][0] = tmp0[i], f[u][i][1] = tmp1[i];
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  if (n == 2) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 2; i <= n; ++i) {
    int x, y;
    cin >> x >> y;
    add(x, y);
    add(y, x);
    ++deg[x], ++deg[y];
  }
  for (int i = 1; i <= n; ++i)
    if (deg[i] != 1) {
      dfs(i, 0);
      assert(sum[i] % 2 == 0);
      cout << min(f[i][sum[i] / 2][0], f[i][sum[i] / 2][1]) << endl;
      break;
    }
  return 0;
}
