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 gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 5000;
const int MAXM = MAXN - 1;
int n;
int head[MAXN];
int nxt[2 * MAXM], to[2 * MAXM];
int cnt[MAXM + 1];
int val[MAXM + 1][MAXN + 1];
void go(int at, int e) {
  cnt[e] = 0, val[e][0] = 0;
  for (int x = head[at]; x != -1; x = nxt[x]) {
    int ne = x >> 1;
    if (ne == e) continue;
    go(to[x], ne);
    for (int i = cnt[e] + cnt[ne]; i >= 0; --i) {
      int nval = INT_MAX;
      for (int i1 = max(0, i - cnt[ne]); i1 <= i && i1 <= cnt[e]; ++i1)
        if (val[e][i1] != INT_MAX && val[ne][i - i1] != INT_MAX &&
            val[e][i1] + val[ne][i - i1] < nval)
          nval = val[e][i1] + val[ne][i - i1];
      for (int i1 = max(0, i - cnt[ne]); i1 <= i && i1 <= cnt[e]; ++i1)
        if (val[e][i1] != INT_MAX && val[ne][i1 + cnt[ne] - i] != INT_MAX &&
            val[e][i1] + val[ne][i1 + cnt[ne] - i] + 1 < nval)
          nval = val[e][i1] + val[ne][i1 + cnt[ne] - i] + 1;
      val[e][i] = nval;
    }
    cnt[e] += cnt[ne];
  }
  if (cnt[e] == 0) cnt[e] = 1, val[e][0] = INT_MAX, val[e][1] = 0;
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) head[i] = -1;
  for (int i = (0); i < (n - 1); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    nxt[2 * i + 0] = head[a];
    head[a] = 2 * i + 0;
    to[2 * i + 0] = b;
    nxt[2 * i + 1] = head[b];
    head[b] = 2 * i + 1;
    to[2 * i + 1] = a;
  }
  if (n == 2) {
    printf("1\n");
    return;
  }
  int root = -1;
  for (int i = (0); i < (n); ++i)
    if (head[i] != -1 && nxt[head[i]] != -1) {
      root = i;
      break;
    }
  assert(root != -1);
  go(root, n - 1);
  printf("%d\n", val[n - 1][cnt[n - 1] / 2]);
}
int main() {
  run();
  return 0;
}
