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;
const int N = 5050;
const int inf = 0x37373737;
int L[N], R[N], size[N], tot, n, i, a, b, cnt, j, k;
int d[N], root;
int dp[N][N];
vector<pair<int, int> > vec[N];
vector<int> e[N];
void dfs(int x, int fa) {
  int i, j, k;
  if (e[x].size() == 1) size[x] = 1;
  for (i = 0; i < e[x].size(); i++)
    if (e[x][i] != fa) {
      dfs(e[x][i], x);
      for (j = size[x]; j >= 0; j--)
        for (k = 0; k <= size[e[x][i]]; k++)
          dp[x][j + k] = min(dp[x][j + k], dp[x][j] + dp[e[x][i]][k]);
      size[x] += size[e[x][i]];
    }
  for (i = 0; i <= size[x]; i++)
    dp[x][i] = min(dp[x][i], dp[x][size[x] - i] + 1);
}
int main() {
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    e[a].push_back(b);
    e[b].push_back(a);
    d[a]++;
    d[b]++;
  }
  if (n == 2) {
    printf("1");
    return 0;
  }
  for (i = 1; i <= n; i++)
    if (d[i] != 1) break;
  root = i;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) dp[i][j] = inf;
  dfs(root, 0);
  printf("%d\n", dp[root][size[root] / 2]);
}
