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
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskF solver = new TaskF();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskF {
        private final int Inf = 0x3f3f3f3f;
        int[] firstEdge;
        int[] nextEdge;
        int[] edgeTo;
        int[] size;
        int[] deg;
        int cntEdges = 0;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            if (n == 2) {
                out.println(1);
                return;
            }

            firstEdge = new int[n];
            Arrays.fill(firstEdge, -1);
            nextEdge = new int[2 * n - 2];
            edgeTo = new int[2 * n - 2];
            deg = new int[n];
            size = new int[n];

            for (int i = 1; i < n; ++i) {
                int x = in.nextInt() - 1, y = in.nextInt() - 1;
                addEdge(x, y);
                addEdge(y, x);
            }

            int leaves = 0;
            for (int i = 0; i < n; ++i)
                if (deg[i] == 1)
                    leaves++;

            int root = 0;
            while (deg[root] == 1) ++root;

            int[][] dp = getDp(root, -1, leaves / 2);

            int ans = Math.min(dp[0][leaves / 2], dp[1][leaves / 2]);
            out.println(ans);
        }

        private void addEdge(int from, int to) {
            deg[from]++;
            edgeTo[cntEdges] = to;
            nextEdge[cntEdges] = firstEdge[from];
            firstEdge[from] = cntEdges++;
        }

        private int[][] getDp(int node, int prev, int limit) {
            if (deg[node] == 1) {
                size[node] = 1;
                int[][] ret = new int[2][2];
                ret[0][1] = Inf;
                ret[1][0] = Inf;
                return ret;
            } else {
                int[][] dp = new int[2][1];
                size[node] = 0;
                for (int p = firstEdge[node]; p != -1; p = nextEdge[p]) {
                    int to = edgeTo[p];
                    if (to == prev) continue;

                    int[][] sdp = getDp(to, node, limit);
                    size[node] += size[to];
                    int maxCard = Math.min(limit, dp[0].length + sdp[0].length - 2);

                    int[][] ndp = new int[2][maxCard + 1];
                    Arrays.fill(ndp[0], Inf);
                    Arrays.fill(ndp[1], Inf);
                    int minCard = Math.max(0, size[node] - limit);
                    for (int type1 = 0; type1 < 2; ++type1) {
                        for (int i = minCard; i <= maxCard; ++i) {
                            for (int type2 = 0; type2 < 2; ++type2) {
                                int add = type1 == type2 ? 0 : 1;

                                int down = Math.max(0, size[to] - limit);
                                down = Math.max(down, i - (dp[0].length - 1));
                                for (int j = down; j < sdp[type2].length && i - j >= 0; ++j) {
                                    ndp[type1][i] = Math.min(ndp[type1][i],
                                            dp[type1][i - j] + sdp[type2][j] + add);
                                }
                            }
                        }
                    }

                    dp = ndp;
                }

                return dp;
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}

