It's election time in Berland. The favorites are of course parties of zublicanes and mumocrates. The election campaigns of both parties include numerous demonstrations on n main squares of the capital of Berland. Each of the n squares certainly can have demonstrations of only one party, otherwise it could lead to riots. On the other hand, both parties have applied to host a huge number of demonstrations, so that on all squares demonstrations must be held. Now the capital management will distribute the area between the two parties.

Some pairs of squares are connected by (n - 1) bidirectional roads such that between any pair of squares there is a unique way to get from one square to another. Some squares are on the outskirts of the capital meaning that they are connected by a road with only one other square, such squares are called dead end squares.

The mayor of the capital instructed to distribute all the squares between the parties so that the dead end squares had the same number of demonstrations of the first and the second party. It is guaranteed that the number of dead end squares of the city is even.

To prevent possible conflicts between the zublicanes and the mumocrates it was decided to minimize the number of roads connecting the squares with the distinct parties. You, as a developer of the department of distributing squares, should determine this smallest number.

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 5000) — the number of squares in the capital of Berland.

Next n - 1 lines contain the pairs of integers x, y (1 ≤ x, y ≤ n, x ≠ y) — the numbers of the squares connected by the road. All squares are numbered with integers from 1 to n. It is guaranteed that the number of dead end squares of the city is even.

Output

Print a single number — the minimum number of roads connecting the squares with demonstrations of different parties.

Examples

Input

8
1 4
2 4
3 4
6 5
7 5
8 5
4 5


Output

1


Input

5
1 2
1 3
1 4
1 5


Output

2
#include <bits/stdc++.h>
using namespace std;
long long getint() {
  long long _x = 0, _tmp = 1;
  char _tc = getchar();
  while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
  if (_tc == '-') _tc = getchar(), _tmp = -1;
  while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();
  return _x * _tmp;
}
long long mypow(long long _a, long long _x, long long _mod) {
  if (_x == 0) return 1ll;
  long long _tmp = mypow(_a, _x / 2, _mod);
  _tmp = (_tmp * _tmp) % _mod;
  if (_x & 1) _tmp = (_tmp * _a) % _mod;
  return _tmp;
}
bool equal(double _x, double _y) { return _x > _y - 1e-9 && _x < _y + 1e-9; }
int __ = 1, cs;
int n, deg[5010], sn;
vector<int> v[5010];
void build() {}
void init() {
  n = getint();
  for (int i = 1; i < n; i++) {
    int tu = getint();
    int tv = getint();
    v[tu].push_back(tv);
    v[tv].push_back(tu);
    deg[tu]++;
    deg[tv]++;
  }
  for (int i = 1; i <= n; i++)
    if (deg[i] != 1) sn = i;
}
int dp[2][5010][5010];
int tdp[2][5010];
int lf[5010], all;
int DFS1(int now, int prt = -1) {
  for (int i = 0; i < (int)v[now].size(); i++)
    if (v[now][i] != prt) lf[now] += DFS1(v[now][i], now);
  if (lf[now] == 0) lf[now] = 1;
  return lf[now];
}
bool cmp(int _x, int _y) { return lf[_x] > lf[_y]; }
void DP(int now, int prt = -1) {
  for (int i = 0; i <= min(lf[now], all); i++)
    dp[0][now][i] = dp[1][now][i] = 5010;
  if (lf[now] == 1) {
    dp[0][now][0] = 0;
    dp[1][now][1] = 0;
    return;
  }
  bool first = true;
  for (int _ = 0; _ < (int)v[now].size(); _++) {
    int son = v[now][_];
    if (son == prt) continue;
    DP(son, now);
    if (first) {
      first = false;
      for (int i = 0; i <= min(lf[son], all); i++) {
        dp[0][now][i] = min(dp[0][son][i], dp[1][son][i] + 1);
        dp[1][now][i] = min(dp[1][son][i], dp[0][son][i] + 1);
      }
    } else {
      for (int i = 0; i <= min(lf[now], all); i++) {
        tdp[0][i] = dp[0][now][i], tdp[1][i] = dp[1][now][i];
        dp[0][now][i] = dp[1][now][i] = 5010;
      }
      for (int i = 0; i <= min(lf[son], all); i++)
        for (int j = min(lf[now], all); j >= i; j--) {
          int nxtdp0 = tdp[0][j - i] + min(dp[0][son][i], dp[1][son][i] + 1);
          int nxtdp1 = tdp[1][j - i] + min(dp[1][son][i], dp[0][son][i] + 1);
          dp[0][now][j] = min(dp[0][now][j], nxtdp0);
          dp[1][now][j] = min(dp[1][now][j], nxtdp1);
        }
    }
  }
}
void solve() {
  DFS1(sn);
  all = lf[sn] / 2;
  for (int i = 1; i <= n; i++) sort((v[i]).begin(), (v[i]).end(), cmp);
  DP(sn);
  printf("%d\n", min(dp[0][sn][all], dp[1][sn][all]));
}
int main() {
  build();
  while (__--) {
    init();
    solve();
  }
}
