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 javafx.util.Pair;

import java.io.*;
import java.util.*;

public class Main {
    class FastScanner {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;
        public FastScanner(InputStream inputStream){
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        }
        public String next() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()){
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException ignored){}
            }
            return stringTokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    private FastScanner scanner;
    private PrintWriter printer;

    Main(InputStream scanner, PrintWriter printWriter) {
        this.scanner = new FastScanner(scanner);
        this.printer = printWriter;
    }

    int gcd (int a, int b) {
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    boolean isPrime(int n) {
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    List<Integer>prostMnoj(int n) {
        ArrayList<Integer> r = new ArrayList<>();
        int p = 2;
        while(n != 1) {
            while(n % p == 0) {
                n /= p;
                r.add(p);
            }
            p++;
            while(!isPrime(p)) {
                p++;
            }
        }
        return r;
    }

    List<Integer>allMnoj(List<Integer>a) {
        ArrayList<Integer>r = new ArrayList<>();
        boolean b[] = new boolean[a.size() + 1];
        while(!b[0]) {
            int i = a.size();
            while(b[i]) {
                i--;
            }
            b[i++] = true;
            while(i<b.length) {
                b[i++] = false;

            }
            int m = 1;
            for (i = 1; i < b.length; i++) {
                if (b[i]) {
                    m*=a.get(i-1);
                }
            }
            r.add(m);
        }
        return r;
    }

    double a(long n) {
        return (180.0 * (n-2)) / n;
    }

    void next (int a[]) {
        for (int i = a.length - 2; i >= 0; i--) {
            if (a[i] < a[i+1]) {
                for (int j = a.length - 1;; j--) {
                    if (a[j] > a[i]) {
                        int t = a[i];
                        a[i] = a[j];
                        a[j] = t;
                        break;
                    }
                }
                for (int j = i + 1; j <= i + ((a.length - 1) - i) / 2; j++) {
                    int t = a[j];
                    int k = (a.length - 1) - (j - (i + 1));
                    a[j] = a[k];
                    a[k] = t;
                }
                break;
            }
        }
    }

    int fact(int n) {
        if (n == 1) return 1;
        return n * fact(n - 1);
    }

    int dfs(List<List<Integer>>g, int v, boolean used[]) {
        if (used[v]) return 0;
        used[v] = true;
        int sum = 1;
        for (int i = 0; i < g.get(v).size(); i++) {
            sum += dfs(g, g.get(v).get(i), used);
        }
        return sum;
    }

    int find(List<List<Integer>>g, int v, int x, boolean used[]) {
        if (used[v]) return -1;
        used[v] = true;
        if (g.get(v).contains(x)) return v;
        for (int i = 0; i < g.get(v).size(); i++) {
            int res = find(g, g.get(v).get(i), x, used);
            if (res != -1) return res;
        }
        return -1;
    }

    int dp[] = new int[101];
    {
        Arrays.fill(dp, -1);
    }

    int[] ms(int n) {
        int dp[] = new int[n + 1];
        int tp[] = new int[n + 1];
        dp[1] = 0;
        tp[1] = 1;
        for (int i = 2; i <= n; i++) {
            int t = i - 1;
            dp[i] = dp[i - 1];
            if (i % 2 == 0 && dp[i / 2] < dp[i]) {
                dp[i] = dp[i / 2];
                t = i / 2;
            }
            if (i % 3 == 0 && dp[i / 3] < dp[i]) {
                dp[i] = dp[i / 3];
                t = i / 3;
            }
            dp[i]++;
            tp[i] = t;
        }
        printer.println(dp[n]);
        int t = n;
        StringBuilder s = new StringBuilder();
        while (t != 1) {
            s.insert(0, t);
            s.insert(0, " ");
            t = tp[t];
        }
        s.insert(0, "1");
        printer.println(s);
        return dp;
    }

    double gg(List<List<Integer>>g, boolean used[], int v) {
        List<Integer> gv = g.get(v);
        used[v] = true;
        if (gv.isEmpty()) return 0;
        if (gv.size() == 1 && used[gv.get(0)]) {
            return 0;
        }
        int k = 0;
        double sum = 0;
        for (int i = 0; i < gv.size(); i++) {
            if (!used[gv.get(i)]) {
                sum += gg(g, used, gv.get(i));
                k++;
            }
        }
        return sum / k + 1;
    }

    void run() {
        int n = scanner.nextInt();
        List<List<Integer>>g = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            g.add(new ArrayList<>());
        }
        for (int i = 0; i < n - 1; i++) {
            int x = scanner.nextInt() - 1;
            int y = scanner.nextInt() - 1;
            g.get(x).add(y);
            g.get(y).add(x);
        }
        printer.println(gg(g, new boolean[n], 0));

        printer.flush();
        printer.close();
    }

    public static void main(String [] args) {
        long start = System.currentTimeMillis();
        new Main(System.in, new PrintWriter(System.out)).run();
        long finish = System.currentTimeMillis();
        System.err.println(finish - start + "ms");
    }
}