#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
void exgcd(long long a, long long b, long long &d, long long &first,
           long long &second) {
  b                          ? exgcd(b, a % b, d, second, first),
      second -= a / b *first : first = 1, second = 0, d = a;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
const int N = 5e3 + 10, INF = 0x3f3f3f3f;
int n, f1[N][N], f2[N][N], t1[N], t2[N];
vector<int> g[N];
int dfs(int first, int fa) {
  if (g[first].size() == 1) {
    f1[first][1] = f2[first][0] = 0;
    return 1;
  }
  f1[first][0] = f2[first][0] = 0;
  int sz = 0;
  for (int second : g[first])
    if (second != fa) {
      int sz1 = dfs(second, first);
      for (int i = 0; i <= sz + sz1; ++i) t1[i] = t2[i] = INF;
      for (int i = 0; i <= sz; ++i)
        for (int j = 0; j <= sz1; ++j) {
          t1[i + j] = min(t1[i + j],
                          f1[first][i] + min(f1[second][j], f2[second][j] + 1));
          t2[i + j] = min(t2[i + j],
                          f2[first][i] + min(f2[second][j], f1[second][j] + 1));
        }
      for (int i = 0; i <= sz + sz1; ++i)
        f1[first][i] = t1[i], f2[first][i] = t2[i];
      sz += sz1;
    }
  return sz;
}
int main() {
  scanf("%d", &n);
  if (n == 2) return puts("1"), 0;
  for (int i = 2; i <= n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v), g[v].push_back(u);
  }
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= n; ++j) f1[i][j] = f2[i][j] = INF;
  int rt;
  for (int i = 1; i <= n; ++i)
    if (g[i].size() > 1) rt = i;
  int sz = dfs(rt, 0);
  printf("%d\n", min(f1[rt][sz / 2], f2[rt][sz / 2]));
}
