Problem: There are n cities and n - 1 roads in the Seven Kingdoms, each road connects two cities and we can reach any city from any other by the roads.

Theon and Yara Greyjoy are on a horse in the first city, they are starting traveling through the roads. But the weather is foggy, so they can’t see where the horse brings them. When the horse reaches a city (including the first one), it goes to one of the cities connected to the current city. But it is a strange horse, it only goes to cities in which they weren't before. In each such city, the horse goes with equal probabilities and it stops when there are no such cities. 

Let the length of each road be 1. The journey starts in the city 1. What is the expected length (expected value of length) of their journey? You can read about expected (average) value by the link <https://en.wikipedia.org/wiki/Expected_value>.

Input

The first line contains a single integer n (1 ≤ n ≤ 100000) — number of cities.

Then n - 1 lines follow. The i-th line of these lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the cities connected by the i-th road.

It is guaranteed that one can reach any city from any other by the roads.

Output

Print a number — the expected length of their journey. The journey starts in the city 1.

Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if <image>.

Examples

Input

4
1 2
1 3
2 4


Output

1.500000000000000


Input

5
1 2
1 3
3 4
2 5


Output

2.000000000000000

Note

In the first sample, their journey may end in cities 3 or 4 with equal probability. The distance to city 3 is 1 and to city 4 is 2, so the expected length is 1.5.

In the second sample, their journey may end in city 4 or 5. The distance to the both cities is 2, so the expected length is 2.

Solution (in JAVA):

Solution:
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;

public class Main
{
    static class Scan
    {
        final private int BUF_SIZE = 1 << 16;
        private int cur_size = 0;
        private int pointer = 0;
        private java.io.DataInputStream in;
        private byte buffer[] = new byte[BUF_SIZE];

        Scan(java.io.InputStream input)
        {
            in = new java.io.DataInputStream(input);
        }

        // fills the buffer with characters
        private void fill() throws java.io.IOException
        {
            cur_size = in.read(buffer, 0, BUF_SIZE);
            if (cur_size == -1) buffer[0] = 0;
            pointer = 0;
        }

        private byte read() throws java.io.IOException
        {
            if (pointer == cur_size) fill();
            return buffer[pointer++];
        }

        int readInt() throws java.io.IOException
        {
            int res = 0;
            byte c;
            while ((c = read()) <= ' ');
            boolean negate = c == '-';
            if (negate) c = read();
            while (c >= '0' && c <= '9')
            {
                res = res * 10 + c - '0';
                c = read();
            }
            return negate ? -res : res;
        }

        long readLong() throws java.io.IOException
        {
            long res = 0;
            byte c;
            while ((c = read()) <= ' ') ;
            boolean negate = c == '-';
            if (negate) c = read();
            while (c >= '0' && c <= '9') {
                res = res * 10 + c - '0';
                c = read();
            }
            return negate ? -res : res;
        }

        double readDouble() throws java.io.IOException
        {
            byte c;
            while ((c = read()) <= ' ');
            boolean negate = c == '-';
            if (negate)
                c = read();
            int power = 0;
            long res = 0;
            boolean dot_flag = false;
            for (;(c >= '0' && c <= '9') || c == '.'; c = read())
            {
                if (dot_flag)
                    power++;
                if (c == '.')
                    dot_flag = true;
                else
                    res = res * 10 + c - '0';
            }
            double ret = res / Math.pow(10, power);
            return negate ? -ret : ret;
        }

        // skip defines whether ' ', '\n', '\r' must be skipped in readChar method
        char readChar(boolean skip) throws java.io.IOException
        {
            if (skip)
            {
                byte c;
                while ((c = read()) == ' ' || c == '\n' || c == '\r');
                return (char) c;
            }
            return (char) read();
        }

        // skip defines whether current string must be skipped in readString and readText methods

        /* If exact length is known, in terms of efficiency
         it is better to specify it while using readText, readString and readWord methods */

        String readWord() throws java.io.IOException
        {
            byte c;
            while ((c = read()) == '\n' || c == ' ' || c == '\r');
            StringBuilder s = new StringBuilder();
            s.append((char)c);
            for (;(c = read()) != '\n' && c != ' ' && c != '\r' && c != 0; s.append((char)c));
            return s.toString();
        }

        String readWord(int LEN) throws java.io.IOException
        {
            byte[] s = new byte[LEN];
            byte c;
            while ((c = read()) == '\n' || c == ' ' || c == '\r');
            s[0] = c;
            for (int i = 1; (c = read()) != ' ' && c != '\n' && c != '\r' && c != 0; s[i++] = c);
            return new String(s);
        }

        String readString(boolean skip, int LEN) throws java.io.IOException
        {
            byte[] s = new byte[LEN];
            byte c;
            if (skip)
                while ((c = read()) != '\n');
            for (int i = 0; (c = read()) != '\n' && c != '\r' && c != 0; s[i++] = c);
            read();
            return new String(s);
        }

        String readString(boolean skip) throws java.io.IOException
        {
            StringBuilder s = new StringBuilder("");
            byte c;
            if (skip)
                while ((c = read()) != '\n');
            for (;(c = read()) != '\n' && c != '\r' && c != 0; s.append((char)c));
            read();
            return s.toString();
        }

        String readText(boolean skip, int LEN) throws java.io.IOException
        {
            byte[] s = new byte[LEN];
            byte c;
            if (skip)
                while ((c = read()) != '\n');
            for (int i = 0; (c = read()) != 0; s[i++] = c);
            return new String(s);
        }

        String readText(boolean skip) throws java.io.IOException
        {
            StringBuilder s = new StringBuilder("");
            byte c;
            if (skip)
                while ((c = read()) != '\n');
            for (;(c = read()) != 0; s.append((char)c));
            return s.toString();
        }
    }

    static class Pair
    {
        double prob;
        int dist;

        Pair(double p, int d)
        {
            prob = p;
            dist = d;
        }
    }

    public static void main(String args[]) throws IOException
    {
        Scan in = new Scan(System.in);
        int n = in.readInt();
        ArrayList<Integer> trans[] = new ArrayList[n];
        int[] cnt = new int[n];
        for (int i = 0; i < n; i++)
        {
            trans[i] = new ArrayList<>();
        }
        for (int i = 0; i < n - 1; i++)
        {
            int from = in.readInt() - 1, to = in.readInt() - 1;
            cnt[from]++;
            cnt[to]++;
            trans[from].add(to);
            trans[to].add(from);
        }
        boolean used[] = new boolean[n];
        used[0] = true;
        LinkedList<Integer> queue = new LinkedList<>();
        Pair dist[] = new Pair[n];
        dist[0] = new Pair(1, 0);
        queue.addLast(0);
        while (!queue.isEmpty())
        {
            int pos = queue.pollFirst();
            for (Integer i : trans[pos])
            {
                if (!used[i])
                {
                    used[i] = true;
                    queue.addLast(i);
                    int k = trans[pos].size();
                    if (pos != 0 && k != 1)
                        k--;
                    dist[i] = new Pair(dist[pos].prob / k, dist[pos].dist + 1);
                }
            }
        }
        double res = 0;
        for (int i = 1; i < n; i++)
        {
            if (cnt[i] == 1)
                res += dist[i].prob * dist[i].dist;
        }
        System.out.println(res);
    }
}