#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5 ;
const double eps = 1e-9 ;
const int MAX_N = 1e6 + 5 ;
const long long M = (long long)1e9+7 ;
#define     ll      long long
#define     ull     unsigned long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%lld",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>inline t abs(t a) { if(a>=0) return a; return -a;}
template<typename t>inline t gcd(t a , t b) {return !b ? a : gcd(b , a % b);}
template<typename t>inline t lcm(t a , t b) {return a * ( b /gcd(a , b));}
template<typename T>inline T modpow(T b, T p, T Mod) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
            res %= Mod ;
        }
        b *= b;
        b %= Mod;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T ModInv(T b, T Mod) {return modpow(b, Mod - 2, Mod );}

template<typename T> inline T pwr(T b, T p) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
        }
        b *= b;
        p >>= 1;
    }
    return res ;
}
int e1 , e2 , d1 ;
template < typename T >inline void extgcd(T a , T b){
    if(!b) {e1 = 1 , e2 = 0 , d1 = a ; return ;}
    extgcd(b , a % b) ;
    T x1 = e2 ;
    T y1 = e1 - (a / b) * e2 ;
    e1 = x1 ;
    e2 = y1 ;
}

/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
/*
std::vector<int> primes;
bitset < MAX_N > bs;
ll sieve_size = MAX_N ;

void sieve(ll n){
    bs.set() ;
    bs[0] = bs[1] = 1 ;
    for(ll i = 2 ; i <= n ; i++)if(bs[i]){
        for(ll j = i * i ; j <= n ; j += i) bs[j] = 0 ;
            primes.push_back((int)i);
    }
}

bool isprime(ll n){
    if(n <= sieve_size)return bs[n] ;
    for(int i = 0 ; i <= (int)primes.size() ; i++){
        if(n % primes[i] == 0)return false ;
    }
    return true ;
}

int numDiffPf[MAX_N] ;

void DiffPF(){
    for(int i = 2 ; i < MAX_N ; i++){
        if(numDiffPf[i] == 0){
            for(int j = i ; j < MAX_N ; j += i)numDiffPf[j]++;
        }
    }
}

int Phi[MAX_N] ;

void EulerPHI(){
    for(int i = 1 ; i < MAX_N ; i++)Phi[i] = i ;
        for(int i = 2 ; i < MAX_N ; i++)
            if(Phi[i] == i)
                for(int j = i ; j < MAX_N ; j += i)
                    Phi[j] = (Phi[j]/i) * (i - 1) ;
}

int F(int x){
    return 0 ;
}
pair < int , int > floydCycle(int x0){
    int tor = F(x0) , hare = F(F(x0)) ;
    while(tor != hare){tor = F(tor) , hare = F(F(hare));}
    int mu = 0 ; hare = x0 ;
    while(tor != hare){tor = F(tor) , hare = F(hare); mu++ ;}
    int lambda = 1 ; hare = F(tor) ;
    while(tor != hare){hare = F(hare) ; lambda++;}
    return {mu , lambda} ;
}
*/
template <typename T>inline vector< T > Unique(vector< T > v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    return v;
}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     ff          first
#define     ss          second
#define     pb            push_back
#define     eb            emplace_back
#define     all(x)      x.begin(),x.end()
#define     mem(a)      memset(a,0,sizeof a)
#define     memn(a)     memset(a,-1,sizeof a)

vector< vector< int > > g;
double prob[N] ;

void dfs(int s , int p = 0){
    int sz = 0 ;
    for(int i : g[s]){
        if(i != p){
            sz++;
            dfs(i , s) ;
            prob[s] += prob[i] ;
        }
    }
    if(sz == 0)return ;
    prob[s] /= 1.0 * sz ;
    prob[s] += 1.0 ;
}

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t = 1 , tc = 0 ;
    while(t--) {
        int n = Int ;
        g.resize(n + 1);
        for(int i = 1 ; i < n ; i++){
            int x = Int , y = Int ;
            g[x].pb(y) ;
            g[y].pb(x) ;
        }
        dfs(1);
        printf("%.10f\n",prob[1]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5 ;
const double eps = 1e-9 ;
const int MAX_N = 1e6 + 5 ;
const long long M = (long long)1e9+7 ;
#define     ll      long long
#define     ull     unsigned long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%lld",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>inline t abs(t a) { if(a>=0) return a; return -a;}
template<typename t>inline t gcd(t a , t b) {return !b ? a : gcd(b , a % b);}
template<typename t>inline t lcm(t a , t b) {return a * ( b /gcd(a , b));}
template<typename T>inline T modpow(T b, T p, T Mod) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
            res %= Mod ;
        }
        b *= b;
        b %= Mod;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T ModInv(T b, T Mod) {return modpow(b, Mod - 2, Mod );}

template<typename T> inline T pwr(T b, T p) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
        }
        b *= b;
        p >>= 1;
    }
    return res ;
}
int e1 , e2 , d1 ;
template < typename T >inline void extgcd(T a , T b){
    if(!b) {e1 = 1 , e2 = 0 , d1 = a ; return ;}
    extgcd(b , a % b) ;
    T x1 = e2 ;
    T y1 = e1 - (a / b) * e2 ;
    e1 = x1 ;
    e2 = y1 ;
}

/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
/*
std::vector<int> primes;
bitset < MAX_N > bs;
ll sieve_size = MAX_N ;

void sieve(ll n){
    bs.set() ;
    bs[0] = bs[1] = 1 ;
    for(ll i = 2 ; i <= n ; i++)if(bs[i]){
        for(ll j = i * i ; j <= n ; j += i) bs[j] = 0 ;
            primes.push_back((int)i);
    }
}

bool isprime(ll n){
    if(n <= sieve_size)return bs[n] ;
    for(int i = 0 ; i <= (int)primes.size() ; i++){
        if(n % primes[i] == 0)return false ;
    }
    return true ;
}

int numDiffPf[MAX_N] ;

void DiffPF(){
    for(int i = 2 ; i < MAX_N ; i++){
        if(numDiffPf[i] == 0){
            for(int j = i ; j < MAX_N ; j += i)numDiffPf[j]++;
        }
    }
}

int Phi[MAX_N] ;

void EulerPHI(){
    for(int i = 1 ; i < MAX_N ; i++)Phi[i] = i ;
        for(int i = 2 ; i < MAX_N ; i++)
            if(Phi[i] == i)
                for(int j = i ; j < MAX_N ; j += i)
                    Phi[j] = (Phi[j]/i) * (i - 1) ;
}

int F(int x){
    return 0 ;
}
pair < int , int > floydCycle(int x0){
    int tor = F(x0) , hare = F(F(x0)) ;
    while(tor != hare){tor = F(tor) , hare = F(F(hare));}
    int mu = 0 ; hare = x0 ;
    while(tor != hare){tor = F(tor) , hare = F(hare); mu++ ;}
    int lambda = 1 ; hare = F(tor) ;
    while(tor != hare){hare = F(hare) ; lambda++;}
    return {mu , lambda} ;
}
*/
template <typename T>inline vector< T > Unique(vector< T > v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    return v;
}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     ff          first
#define     ss          second
#define     pb            push_back
#define     eb            emplace_back
#define     all(x)      x.begin(),x.end()
#define     mem(a)      memset(a,0,sizeof a)
#define     memn(a)     memset(a,-1,sizeof a)

vector< vector< int > > g;
double prob[N] ;

void dfs(int s , int p = 0){
    for(int i : g[s]){
        if(i != p){
            if(s == 1){
                prob[i] = 1 ;
            }
            else{
                int sz = (int)g[s].size() ;
                prob[i] = prob[s] + (1.0 / (1.0 * (sz - 1))) ;
            }
            dfs(i , s) ;
        }
    }
}

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t = 1 , tc = 0 ;
    while(t--) {
        int n = Int ;
        g.resize(n + 1);
        for(int i = 1 ; i < n ; i++){
            int x = Int , y = Int ;
            g[x].pb(y) ;
            g[y].pb(x) ;
        }
        dfs(1);
        int leaf = 0 ;
        double tot = 0 ;
        for(int i = 2 ; i <= n ; i++){
            if((int)g[i].size() == 1){
                leaf++;
                tot += prob[i] ;
            }
        }
        tot = tot / (1.0 * leaf);
        printf("%.10f\n",tot);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll           long long
#define N            100005
#define Fill(a,b)    memset(a,b,sizeof a)

int dist[N];
int vis[N];
vector<pair <int,int> >nod[N];
void dijkstra(int s) {
    priority_queue< pair <int,int> >pq;
    for(int i=0; i<N; i++) {
        vis[i]=0,dist[i]= INT_MAX;
    }
    pq.push(make_pair(0,s));
    vis[s]=true;
    dist[s]=0;
    //stk.push(n);
    while(!pq.empty()) {
        ll u = pq.top().second;
        vis[u]=true;
        pq.pop();
        for(int i=0; i<nod[u].size(); i++) {
            int p = nod[u][i].first;
            int q = nod[u][i].second;
            if(dist[p]>dist[u]+q) {
                dist[p]=dist[u]+q;
                if(!vis[p])
                    pq.push(make_pair(-1*dist[p],p));
            }
        }
    }
}
int main() {
    int u,v,w,i,j,n,m;
    scanf("%d",&n);
    for(i=1; i<n; i++) {
        int l,r;
        scanf("%d%d",&l,&r);
        nod[l].push_back({r,1});
        nod[r].push_back({l,1});
    }
    dijkstra(1);
    int sum=0,cnt=0;
    for(int i=2; i<=n; i++) {
        if(nod[i].size()==1) {
            sum+=dist[i];
            cnt++;
        }
    }
    cerr<<sum<< " " <<cnt<<endl;
    printf("%.6f\n",(1.0*sum)/(1.0*cnt));

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5 ;
const double eps = 1e-9 ;
const int MAX_N = 1e6 + 5 ;
const long long M = (long long)1e9+7 ;
#define     ll      long long
#define     ull     unsigned long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%lld",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>inline t abs(t a) { if(a>=0) return a; return -a;}
template<typename t>inline t gcd(t a , t b) {return !b ? a : gcd(b , a % b);}
template<typename t>inline t lcm(t a , t b) {return a * ( b /gcd(a , b));}
template<typename T>inline T modpow(T b, T p, T Mod) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
            res %= Mod ;
        }
        b *= b;
        b %= Mod;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T ModInv(T b, T Mod) {return modpow(b, Mod - 2, Mod );}

template<typename T> inline T pwr(T b, T p) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
        }
        b *= b;
        p >>= 1;
    }
    return res ;
}
int e1 , e2 , d1 ;
template < typename T >inline void extgcd(T a , T b){
    if(!b) {e1 = 1 , e2 = 0 , d1 = a ; return ;}
    extgcd(b , a % b) ;
    T x1 = e2 ;
    T y1 = e1 - (a / b) * e2 ;
    e1 = x1 ;
    e2 = y1 ;
}

/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
/*
std::vector<int> primes;
bitset < MAX_N > bs;
ll sieve_size = MAX_N ;

void sieve(ll n){
    bs.set() ;
    bs[0] = bs[1] = 1 ;
    for(ll i = 2 ; i <= n ; i++)if(bs[i]){
        for(ll j = i * i ; j <= n ; j += i) bs[j] = 0 ;
            primes.push_back((int)i);
    }
}

bool isprime(ll n){
    if(n <= sieve_size)return bs[n] ;
    for(int i = 0 ; i <= (int)primes.size() ; i++){
        if(n % primes[i] == 0)return false ;
    }
    return true ;
}

int numDiffPf[MAX_N] ;

void DiffPF(){
    for(int i = 2 ; i < MAX_N ; i++){
        if(numDiffPf[i] == 0){
            for(int j = i ; j < MAX_N ; j += i)numDiffPf[j]++;
        }
    }
}

int Phi[MAX_N] ;

void EulerPHI(){
    for(int i = 1 ; i < MAX_N ; i++)Phi[i] = i ;
        for(int i = 2 ; i < MAX_N ; i++)
            if(Phi[i] == i)
                for(int j = i ; j < MAX_N ; j += i)
                    Phi[j] = (Phi[j]/i) * (i - 1) ;
}

int F(int x){
    return 0 ;
}
pair < int , int > floydCycle(int x0){
    int tor = F(x0) , hare = F(F(x0)) ;
    while(tor != hare){tor = F(tor) , hare = F(F(hare));}
    int mu = 0 ; hare = x0 ;
    while(tor != hare){tor = F(tor) , hare = F(hare); mu++ ;}
    int lambda = 1 ; hare = F(tor) ;
    while(tor != hare){hare = F(hare) ; lambda++;}
    return {mu , lambda} ;
}
*/
template <typename T>inline vector< T > Unique(vector< T > v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    return v;
}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     ff          first
#define     ss          second
#define     pb            push_back
#define     eb            emplace_back
#define     all(x)      x.begin(),x.end()
#define     mem(a)      memset(a,0,sizeof a)
#define     memn(a)     memset(a,-1,sizeof a)

vector< vector< int > > g;
double prob[N] ;

void dfs(int s , int p = 0){
    for(int i : g[s]){
        if(i != p){
            if(s == 1){
                prob[i] = 1 ;
            }
            else prob[i] = prob[s] + (prob[s] / (1.0 * (int)g[s].size() - 1)) ;
            dfs(i , s) ;
        }
    }
}

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t = 1 , tc = 0 ;
    while(t--) {
        int n = Int ;
        g.resize(n + 1);
        for(int i = 1 ; i < n ; i++){
            int x = Int , y = Int ;
            g[x].pb(y) ;
            g[y].pb(x) ;
        }
        dfs(1);
        int leaf = 0 ;
        double tot = 0 ;
        for(int i = 2 ; i <= n ; i++){
            if(g[i].size() == 1){
                leaf++;
                tot += prob[i] ;
               // error(i , prob[i])
            }
        }
        tot = tot / leaf ;
        printf("%.10f\n",tot);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N =1e6+5;
const long long M = (long long)1e9+7;
#define     ll      long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%I64d",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>t abs(t a) {
    if(a>=0)return a;
    return -a;
}
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     vi          vector<int>
#define     vl          vector<ll>
#define     pb          push_back
#define     all(x)      x.begin(),x.end()
#define     LB          lower_bound
#define     UB          upper_bound
#define     Mx(a,b)     (a>b)?a:b
#define     Mn(a,b)     (a<b)?a:b
#define     mem(a,b)    memset(a,b,sizeof a)

int col[N],vis[N];
vi g[N],nw;

vector<vi>v;

void dfs(int s, int p =-1) {
    vis[s]=1;
    for(auto u : g[s]) {
        if(u!=p and vis[u]==0) {
            col[u]=col[s]+1;
            dfs(u,s);

        }
    }

}

int main() {

    int n=Int;
    for(int i=1; i<n; i++) {
        int l=Int,r=Int;
        g[l].pb(r);
        g[r].pb(l);
    }
    dfs(1);
    int cn=0,sum=0;
    for(int i=2; i<=n; i++) {
        if(g[i].size()==1) {
            cn++;
            sum+=col[i];
        }
    }
    ///error(sum,cn);
    double x= (1.0*sum)/(1.0*cn);
    //error(x);
    printf("%.6f\n",x);
}


#include<bits/stdc++.h>
using namespace std;
const int N =1e6+5;
#define ll           long long
#define Fill(a,b)    memset(a,b,sizeof a)

int dist[N];
int vis[N];

vector<pair <int,int> >nod[N];

void dijkstra(int s) {

    priority_queue< pair <int,int> >pq;

    for(int i=0; i<N; i++) {
        vis[i]=0,dist[i]= INT_MAX;
    }

    pq.push({0,s});
    vis[s]=true;
    dist[s]=0;

    while(!pq.empty()) {

        int u = pq.top().second;
        vis[u]=true;
        pq.pop();

        for(int i=0; i<nod[u].size(); i++) {
            int p = nod[u][i].first;
            int q = nod[u][i].second;

            if(dist[p]>dist[u]+q) {
                dist[p]=dist[u]+q;
                if(!vis[p])
                    pq.push({-1*dist[p],p});
            }
        }
    }
}
int main() {
    int u,v,w,i,j,n,m;
    scanf("%d",&n);
    if(n==1)
        return puts("0.0000000"),0;
    for(i=1; i<n; i++) {
        int l,r;
        scanf("%d%d",&l,&r);
        nod[l].push_back({r,1});
        nod[r].push_back({l,1});
    }
    dijkstra(1);
    int sum=0,cnt=0;
    for(int i=2; i<=n; i++) {
        if(nod[i].size()==1) {
            sum+=dist[i];
            cnt++;
        }
    }
    //cerr<<sum<< " " <<cnt<<endl;
    printf("%.10f\n",(1.0*sum)/(1.0*cnt));
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N =1e6+5;
#define ll           long long
#define Fill(a,b)    memset(a,b,sizeof a)

int dist[N];
int vis[N];

vector<pair <int,int> >nod[N];

void dijkstra(int s) {

    priority_queue< pair <int,int> >pq;

    for(int i=0; i<N; i++) {
        vis[i]=0,dist[i]= INT_MAX;
    }

    pq.push({0,s});
    vis[s]=true;
    dist[s]=0;

    while(!pq.empty()) {

        int u = pq.top().second;
        vis[u]=true;
        pq.pop();

        for(int i=0; i<nod[u].size(); i++) {
            int p = nod[u][i].first;
            int q = nod[u][i].second;

            if(dist[p]>dist[u]+q) {
                dist[p]=dist[u]+q;
                if(!vis[p])
                    pq.push({-1*dist[p],p});
            }
        }
    }
}
int main() {
    int u,v,w,i,j,n,m;
    scanf("%d",&n);
    if(n==1)
        return puts("0.0000000"),0;
    for(i=1; i<n; i++) {
        int l,r;
        scanf("%d%d",&l,&r);
        nod[l].push_back({r,1});
        nod[r].push_back({l,1});
    }
    dijkstra(1);
    ll sum=0;
    int cnt=0;
    for(int i=2; i<=n; i++) {
        if(nod[i].size()==1) {
            sum+=1LL*dist[i];
            cnt++;
        }
    }
    //cerr<<sum<< " " <<cnt<<endl;
    printf("%.10f\n",(1.0*sum)/(1.0*cnt));
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N =1e6+5;
const long long M = (long long)1e9+7;
#define     ll      long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%I64d",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>t abs(t a) {
    if(a>=0)return a;
    return -a;
}
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     vi          vector<int>
#define     vl          vector<ll>
#define     pb          push_back
#define     all(x)      x.begin(),x.end()
#define     LB          lower_bound
#define     UB          upper_bound
#define     Mx(a,b)     (a>b)?a:b
#define     Mn(a,b)     (a<b)?a:b
#define     mem(a,b)    memset(a,b,sizeof a)

int col[N],vis[N];
vi g[N],nw;

vector<vi>v;

void dfs(int s, int p =-1) {
    vis[s]=1;
    for(auto u : g[s]) {
        if(u!=p and vis[u]==0) {
            col[u]=col[s]+1;
            dfs(u,s);

        }
    }

}

int main() {

    int n=Int;
    for(int i=1; i<n; i++) {
        int l=Int,r=Int;
        g[l].pb(r);
        g[r].pb(l);
    }
    dfs(1);
    int cn=0,sum=0;
    for(int i=2; i<=n; i++) {
        if(g[i].size()==1) {
            cn++;
            sum+=col[i];
        }
    }
    error(sum,cn);
    double x= (1.0*sum)/(1.0*cn);
    //error(x);
    printf("%.6f\n",x);
}


#include<bits/stdc++.h>
using namespace std;
#define ll           long long
#define N            100005
#define Fill(a,b)    memset(a,b,sizeof a)

int dist[N];
int vis[N];
vector<pair <int,int> >nod[N];
void dijkstra(int s) {
    priority_queue< pair <int,int> >pq;
    for(int i=0; i<N; i++) {
        vis[i]=0,dist[i]= INT_MAX;
    }
    pq.push(make_pair(0,s));
    vis[s]=true;
    dist[s]=0;
    //stk.push(n);
    while(!pq.empty()) {
        ll u = pq.top().second;
        vis[u]=true;
        pq.pop();
        for(int i=0; i<nod[u].size(); i++) {
            int p = nod[u][i].first;
            int q = nod[u][i].second;
            if(dist[p]>dist[u]+q) {
                dist[p]=dist[u]+q;
                if(!vis[p])
                    pq.push(make_pair(-1*dist[p],p));
            }
        }
    }
}
int main() {
    int u,v,w,i,j,n,m;
    scanf("%d",&n);
    if(n==1)
        return puts("0.0000000"),0;
    for(i=1; i<n; i++) {
        int l,r;
        scanf("%d%d",&l,&r);
        nod[l].push_back({r,1});
        nod[r].push_back({l,1});
    }
    dijkstra(1);
    int sum=0,cnt=0;
    for(int i=2; i<=n; i++) {
        if(nod[i].size()==1) {
            sum+=dist[i];
            cnt++;
        }
    }
    //cerr<<sum<< " " <<cnt<<endl;
    printf("%.6f\n",(1.0*sum)/(1.0*cnt));

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5 ;
const double eps = 1e-9 ;
const int MAX_N = 1e6 + 5 ;
const long long M = (long long)1e9+7 ;
#define     ll      long long
#define     ull     unsigned long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%lld",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>inline t abs(t a) { if(a>=0) return a; return -a;}
template<typename t>inline t gcd(t a , t b) {return !b ? a : gcd(b , a % b);}
template<typename t>inline t lcm(t a , t b) {return a * ( b /gcd(a , b));}
template<typename T>inline T modpow(T b, T p, T Mod) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
            res %= Mod ;
        }
        b *= b;
        b %= Mod;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T ModInv(T b, T Mod) {return modpow(b, Mod - 2, Mod );}

template<typename T> inline T pwr(T b, T p) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
        }
        b *= b;
        p >>= 1;
    }
    return res ;
}
int e1 , e2 , d1 ;
template < typename T >inline void extgcd(T a , T b){
    if(!b) {e1 = 1 , e2 = 0 , d1 = a ; return ;}
    extgcd(b , a % b) ;
    T x1 = e2 ;
    T y1 = e1 - (a / b) * e2 ;
    e1 = x1 ;
    e2 = y1 ;
}

/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
/*
std::vector<int> primes;
bitset < MAX_N > bs;
ll sieve_size = MAX_N ;

void sieve(ll n){
    bs.set() ;
    bs[0] = bs[1] = 1 ;
    for(ll i = 2 ; i <= n ; i++)if(bs[i]){
        for(ll j = i * i ; j <= n ; j += i) bs[j] = 0 ;
            primes.push_back((int)i);
    }
}

bool isprime(ll n){
    if(n <= sieve_size)return bs[n] ;
    for(int i = 0 ; i <= (int)primes.size() ; i++){
        if(n % primes[i] == 0)return false ;
    }
    return true ;
}

int numDiffPf[MAX_N] ;

void DiffPF(){
    for(int i = 2 ; i < MAX_N ; i++){
        if(numDiffPf[i] == 0){
            for(int j = i ; j < MAX_N ; j += i)numDiffPf[j]++;
        }
    }
}

int Phi[MAX_N] ;

void EulerPHI(){
    for(int i = 1 ; i < MAX_N ; i++)Phi[i] = i ;
        for(int i = 2 ; i < MAX_N ; i++)
            if(Phi[i] == i)
                for(int j = i ; j < MAX_N ; j += i)
                    Phi[j] = (Phi[j]/i) * (i - 1) ;
}

int F(int x){
    return 0 ;
}
pair < int , int > floydCycle(int x0){
    int tor = F(x0) , hare = F(F(x0)) ;
    while(tor != hare){tor = F(tor) , hare = F(F(hare));}
    int mu = 0 ; hare = x0 ;
    while(tor != hare){tor = F(tor) , hare = F(hare); mu++ ;}
    int lambda = 1 ; hare = F(tor) ;
    while(tor != hare){hare = F(hare) ; lambda++;}
    return {mu , lambda} ;
}
*/
template <typename T>inline vector< T > Unique(vector< T > v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    return v;
}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     ff          first
#define     ss          second
#define     pb            push_back
#define     eb            emplace_back
#define     all(x)      x.begin(),x.end()
#define     mem(a)      memset(a,0,sizeof a)
#define     memn(a)     memset(a,-1,sizeof a)

vector< vector< int > > g;
double prob[N] ;

void dfs(int s , int p = 0){
    for(int i : g[s]){
        if(i != p){
            if(s == 1){
                prob[i] = 1 ;
            }
            else prob[i] = prob[s] + (prob[s] / (1.0 * (int)g[s].size() - 1)) ;
            dfs(i , s) ;
        }
    }
}

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t = 1 , tc = 0 ;
    while(t--) {
        int n = Int ;
        g.resize(n + 1);
        for(int i = 1 ; i < n ; i++){
            int x = Int , y = Int ;
            g[x].pb(y) ;
            g[y].pb(x) ;
        }
        dfs(1);
        int leaf = 0 ;
        double tot = 0 ;
        for(int i = 2 ; i <= n ; i++){
            if((int)g[i].size() == 1){
                leaf++;
                tot += prob[i] ;
               // error(i , prob[i])
            }
        }
        tot = tot / (1.0*leaf);
        printf("%.10f\n",tot);
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure
typedef tree<int, null_type,
			less_equal<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	indexed_set;
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 100009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll>
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/
ll n;
vi adj[N];
vi len;
void dfs(ll node,ll p,ll d=0){
	if(adj[node].size()==1){
		len.eb(d);
		return;
	}
	for(auto c:adj[node]){
		if(c==p)
			continue;
		dfs(c,node,d+1);
	}
}
void solve(){
	cin>>n;
	rep(i,1,n){
		ll u,v;
		cin>>u>>v;
		adj[u].eb(v);
		adj[v].eb(u);
	}
	dfs(1,-1);
	ll total=0;
	map<ll,ll> mp;
	for(auto ele:len){
		mp[ele]++;
		total++;
	}
	ll x=0;
	for(auto p:mp){
		x+=(p.F * p.S);
	}
// 	if(n==2000){
// 		cout<<total<<endl;
// 		sout("x",x);
// 	}
	cout<<fixed<<setprecision(15)<<(double)(x)/total<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure
typedef tree<int, null_type,
			less_equal<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	indexed_set;
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 100009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll>
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/
ll n;
vi adj[N];
vi len;
void dfs(ll node,ll p,ll d=0){
	if(adj[node].size()==1){
		len.eb(d);
		return;
	}
	for(auto c:adj[node]){
		if(c==p)
			continue;
		dfs(c,node,d+1);
	}
}
void solve(){
	cin>>n;
	rep(i,1,n){
		ll u,v;
		cin>>u>>v;
		adj[u].eb(v);
		adj[v].eb(u);
	}
	dfs(1,-1);
	ll total=0;
	map<int,int> mp;
	for(auto ele:len){
		mp[ele]++;
		total++;
	}
	ll x=0;
	for(auto p:mp){
		x+=(p.F * p.S);
	}
	if(n==2000){
		cout<<total<<endl;
		sout("x",x);
	}
	cout<<fixed<<setprecision(15)<<(double)(x)/total<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure
typedef tree<int, null_type,
			less_equal<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	indexed_set;
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 100009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll>
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/
ll n;
vi adj[N];
vi len;
void dfs(ll node,ll p,ll d=0){
	if(adj[node].size()==1 and adj[node][0]==p){
		len.eb(d);
		return;
	}
	for(auto c:adj[node]){
		if(c==p)
			continue;
		dfs(c,node,d+1);
	}
}
void solve(){
	cin>>n;
	rep(i,1,n){
		ll u,v;
		cin>>u>>v;
		adj[u].eb(v);
		adj[v].eb(u);
	}
	dfs(1,-1);
	ll total=0;
	map<ll,ll> mp;
	for(auto ele:len){
		mp[ele]++;
		total++;
	}
	ll x=0;
	for(auto p:mp){
		x+=(p.F * p.S);
	}
	if(n==300){
		cout<<total<<endl;
		sout("x",x);
		sout("size",mp.size());
		for(auto p:mp){
			sout(p.F,p.S);
		}
	}
	cout<<fixed<<setprecision(15)<<(double)(x)/total<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure
typedef tree<int, null_type,
			less_equal<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	indexed_set;
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 100009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll>
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/
ll n;
vi adj[N];
vi len;
void dfs(ll node,ll p,ll d=0){
	if(adj[node].size()==1){
		len.eb(d);
		return;
	}
	for(auto c:adj[node]){
		if(c==p)
			continue;
		dfs(c,node,d+1);
	}
}
void solve(){
	cin>>n;
	rep(i,1,n){
		ll u,v;
		cin>>u>>v;
		adj[u].eb(v);
		adj[v].eb(u);
	}
	dfs(1,-1);
	ll total=0;
	map<ll,ll> mp;
	for(auto ele:len){
		mp[ele]++;
		total++;
	}
	ll x=0;
	for(auto p:mp){
		x+=(p.F * p.S);
	}
	if(n==2000){
		cout<<total<<endl;
		sout("x",x);
		sout("size",mp.size());
		for(auto p:mp){
			sout(p.F,p.S);
		}
	}
	cout<<fixed<<setprecision(15)<<(double)(x)/total<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure
typedef tree<int, null_type,
			less_equal<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	indexed_set;
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 100009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll>
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/
ll n;
vi adj[N];
double dfs(ll node,ll p,ll d=0){
	ll cnt=0;
	double total=0;
	for(auto c:adj[node]){
		if(c==p)
			continue;
		total=total+1.0+dfs(c,node,d+1);
		cnt++;
	}
	if(cnt==0){
		return 0.0;
	}
	return total/cnt;
}
void solve(){
	cin>>n;
	rep(i,1,n){
		ll u,v;
		cin>>u>>v;
		adj[u].eb(v);
		adj[v].eb(u);
	}
	// dfs(1,-1);
	double ans=dfs(1,-1);
	cout<<fixed<<setprecision(15)<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure
typedef tree<int, null_type,
			less_equal<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	indexed_set;
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 100009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll>
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/
ll n;
vi adj[N];
vi len;
void dfs(ll node,ll p,ll d=0){
	if(adj[node].size()==1 and adj[node][0]==p){
		len.eb(d);
		return;
	}
	for(auto c:adj[node]){
		if(c==p)
			continue;
		dfs(c,node,d+1);
	}
}
void solve(){
	cin>>n;
	rep(i,1,n){
		ll u,v;
		cin>>u>>v;
		adj[u].eb(v);
		adj[v].eb(u);
	}
	dfs(1,-1);
	ll total=0;
	map<ll,ll> mp;
	for(auto ele:len){
		mp[ele]++;
		total++;
	}
	ll x=0;
	for(auto p:mp){
		x+=(p.F * p.S);
	}
	// if(n==2000){
	// 	cout<<total<<endl;
	// 	sout("x",x);
	// 	sout("size",mp.size());
	// 	for(auto p:mp){
	// 		sout(p.F,p.S);
	// 	}
	// }
	cout<<fixed<<setprecision(15)<<(double)(x)/total<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure
typedef tree<int, null_type,
			less_equal<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	indexed_set;
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 100009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll>
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/
ll n;
vi adj[N];
vi len;
void dfs(ll node,ll p,ll d=0){
	if(adj[node].size()==1){
		len.eb(d);
		return;
	}
	for(auto c:adj[node]){
		if(c==p)
			continue;
		dfs(c,node,d+1);
	}
}
void solve(){
	cin>>n;
	rep(i,1,n){
		ll u,v;
		cin>>u>>v;
		adj[u].eb(v);
		adj[v].eb(u);
	}
	dfs(1,-1);
	ll total=0;
	map<int,int> mp;
	for(auto ele:len){
		mp[ele]++;
		total++;
	}
	ll x=0;
	for(auto p:mp){
		x+=(p.F * p.S);
	}
	if(n==2000){
		cout<<total<<endl;
	}
	cout<<fixed<<setprecision(15)<<(double)(x)/total<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure
typedef tree<int, null_type,
			less_equal<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	indexed_set;
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 100009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll>
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/
ll n;
vi adj[N];
vi len;
void dfs(ll node,ll p,ll d=0){
	ll cnt=0;
	for(auto c:adj[node]){
		if(c==p)
			continue;
		dfs(c,node,d+1);
		cnt++;
	}
	if(cnt==0){
		len.eb(d);
	}
}
void solve(){
	cin>>n;
	rep(i,1,n){
		ll u,v;
		cin>>u>>v;
		adj[u].eb(v);
		adj[v].eb(u);
	}
	dfs(1,-1);
	ll total=0;
	map<ll,ll> mp;
	for(auto ele:len){
		mp[ele]++;
		total++;
	}
	ll x=0;
	for(auto p:mp){
		x+=(p.F * p.S);
	}
	// if(n==300){
	// 	cout<<total<<endl;
	// 	sout("x",x);
	// 	sout("size",mp.size());
	// 	for(auto p:mp){
	// 		sout(p.F,p.S);
	// 	}
	// }
	cout<<fixed<<setprecision(15)<<(double)(x)/total<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure
typedef tree<int, null_type,
			less_equal<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	indexed_set;
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 100009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll>
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/
ll n;
vi adj[N];
vi len;
void dfs(ll node,ll p,ll d=0){
	if(adj[node].size()==1){
		len.eb(d);
		return;
	}
	for(auto c:adj[node]){
		if(c==p)
			continue;
		dfs(c,node,d+1);
	}
}
void solve(){
	cin>>n;
	rep(i,1,n){
		ll u,v;
		cin>>u>>v;
		adj[u].eb(v);
		adj[v].eb(u);
	}
	dfs(1,-1);
	ll total=0;
	map<int,int> mp;
	for(auto ele:len){
		mp[ele]++;
		total++;
	}
	ll x=0;
	for(auto p:mp){
		x+=(p.F * p.S);
	}
	cout<<fixed<<setprecision(15)<<(double)(x)/total<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure
typedef tree<int, null_type,
			less_equal<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	indexed_set;
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 100009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll>
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/
ll n;
vi adj[N];
vi len;
void dfs(ll node,ll p,ll d=0){
	if(adj[node].size()==1){
		len.eb(d);
		return;
	}
	for(auto c:adj[node]){
		if(c==p)
			continue;
		dfs(c,node,d+1);
	}
}
void solve(){
	cin>>n;
	rep(i,1,n){
		ll u,v;
		cin>>u>>v;
		adj[u].eb(v);
		adj[v].eb(u);
	}
	dfs(1,-1);
	ll total=0;
	map<ll,ll> mp;
	for(auto ele:len){
		mp[ele]++;
		total++;
	}
	ll x=0;
	for(auto p:mp){
		x+=(p.F * p.S);
	}
	if(n==2000){
		cout<<total<<endl;
		sout("x",x);
		sout("size",mp.size());
	}
	cout<<fixed<<setprecision(15)<<(double)(x)/total<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure
typedef tree<int, null_type,
			less_equal<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	indexed_set;
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 100009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll>
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/
ll n;
vi adj[N];
double dfs(ll node,ll p,ll d=0){
	ll cnt=0;
	double total=0;
	for(auto c:adj[node]){
		if(c==p)
			continue;
		total=total+1+dfs(c,node,d+1);
		cnt++;
	}
	if(cnt==0){
		return 0.0;
	}
	return total/cnt;
}
void solve(){
	cin>>n;
	rep(i,1,n){
		ll u,v;
		cin>>u>>v;
		adj[u].eb(v);
		adj[v].eb(u);
	}
	// dfs(1,-1);
	double ans=dfs(1,-1);
	cout<<fixed<<setprecision(15)<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define inf ((ll)1e18+1))
vector<ll>adj[200005];
vector<ll>vis(200005,0);
double res=0.0;
void dfs(ll v,double prob,ll depth)
{
    vis[v]=1;
    ll c=0;
    for(auto i:adj[v])
    {
        if(!vis[i])
        c++;
    }
    for(auto i:adj[v])
    {
        if(!vis[i])
        dfs(i,prob/c,depth+1);
    }
    if(c==0)//LEAF NODE
    {
    res+=prob*depth;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    //cin>>t;
        while(t--)
        {
              ll n,k;
              cin>>n>>k;
              ll i;
              for(i=1;i<=n-1;i++)
              {
                  ll x,y;
                  cin>>x>>y;
                  x--;
                  y--;
                  adj[x].push_back(y);
                  adj[y].push_back(x);
              }
             dfs(0,1.0,0);
             printf("%.6f",res);
             cout<<res<<endl;
        }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define inf ((ll)1e18+1))
vector<ll>adj[200005];
vector<ll>vis(200005,0);
double res=0.0;
void dfs(ll v,double prob,ll depth)
{
    vis[v]=1;
    ll c=0;
    for(auto i:adj[v])
    {
        if(!vis[i])
        c++;
    }
    for(auto i:adj[v])
    {
        if(!vis[i])
        dfs(i,prob/c,depth+1);
    }
    if(c==0)//LEAF NODE
    {
    res+=prob*depth;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    //cin>>t;
        while(t--)
        {
              ll n,k;
              cin>>n>>k;
              ll i;
              for(i=1;i<=n-1;i++)
              {
                  ll x,y;
                  cin>>x>>y;

                  adj[x].push_back(y);
                  adj[y].push_back(x);
              }
             dfs(1,1.0,0);
             printf("%.6f",res);
             cout<<res<<endl;
        }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define inf ((ll)1e18+1))
vector<ll>adj[200005];
vector<ll>vis(200005,0);
double res=0.0;
void dfs(ll v,double prob,ll depth)
{
    if(vis[v])
    return;
    vis[v]=1;
    ll c=0;
    for(auto i:adj[v])
    {
        if(!vis[i])
        c++;
    }
    for(auto i:adj[v])
    {
        if(!vis[i])
        dfs(i,prob/c,depth+1);
    }
    if(c==0)//LEAF NODE
    {
    res+=prob*depth;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    //cin>>t;
        while(t--)
        {
              ll n;
              cin>>n;
              ll i;
              for(i=1;i<=n-1;i++)
              {
                  ll x,y;
                  cin>>x>>y;
                  adj[x].push_back(y);
                  adj[y].push_back(x);
              }
             dfs(1,1.0,0);
             cout<<fixed<<setprecision(7)<<res<<endl;
        }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define inf ((ll)1e18+1))
vector<ll>adj[200005];
vector<ll>vis(200005,0);
vector<ll>l(200005,0);
void dfs(ll v,ll k)
{
    vis[v]=1;
    l[v]=k;
    for(auto i:adj[v])
    {
        if(!vis[i])
        dfs(i,k+1);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    //cin>>t;
        while(t--)
        {
              ll n;
              cin>>n;
              ll i;
              for(i=1;i<=n-1;i++)
              {
                  ll x,y;
                  cin>>x>>y;
                  adj[x].push_back(y);
              }
             dfs(1,0);
             double res=0,s=0,c=0;
             for(i=1;i<=n;i++)
             {
                if(adj[i].size()==0)
                {
                   s+=l[i];
                   c++;
                }
             }
             res=s/c;
           printf("%.15f",res);
        }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define inf ((ll)1e18+1))
vector<ll>adj[200005];
vector<ll>vis(200005,0);
double res=0.0;
void dfs(ll v,double prob,ll depth)
{

    vis[v]=1;
    ll c=0;
    for(auto i:adj[v])
    {
        if(!vis[i])
        c++;
    }
    for(auto i:adj[v])
    {
        if(!vis[i])
        dfs(i,prob/c,depth+1);
    }
    if(c==0)//LEAF NODE
    {
    res+=prob*depth;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    //cin>>t;
        while(t--)
        {
              ll n;
              cin>>n;
              ll i;
              for(i=1;i<=n-1;i++)
              {
                  ll x,y;
                  cin>>x>>y;
                  x--;
                  y--;
                  adj[x].push_back(y);
                  adj[y].push_back(x);
              }
             dfs(0,1.0,0);
             cout<<fixed<<setprecision(7)<<res<<endl;
        }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define inf ((ll)1e18+1))
vector<ll>adj[200005];
vector<ll>vis(200005);
double res=0.0;
void dfs(ll v,double prob,ll depth)
{
    if(vis[v])
    return;
    vis[v]=1;
    ll c=0;
    for(auto i:adj[v])
    {
        if(!vis[i])
        c++;
    }
    for(auto i:adj[v])
    {
        if(!vis[i])
        dfs(i,prob/c,depth+1);
    }
    if(c==0)//LEAF NODE
    {
    res+=prob*depth;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    //cin>>t;
        while(t--)
        {
              ll n,k;
              cin>>n>>k;
              ll i;
              memset(vis,0,sizeof(vis));
              for(i=1;i<=n-1;i++)
              {
                  ll x,y;
                  cin>>x>>y;
                  x--;
                  y--;
                  adj[x].push_back(y);
                  adj[y].push_back(x);
              }
             dfs(0,1.0,0);
             cout<<fixed<<setprecision(7)<<res<<endl;
        }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define inf ((ll)1e18+1))
vector<ll>adj[200005];
vector<ll>vis(200005,0);
double res=0.0;
void dfs(ll v,double prob,ll depth)
{
    vis[v]=1;
    ll c=0;
    for(auto i:adj[v])
    {
        if(!vis[i])
        c++;
    }
    for(auto i:adj[v])
    {
        if(!vis[i])
        dfs(i,prob/c,depth+1);
    }
    if(c==0)//LEAF NODE
    {
    res+=prob*depth;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    //cin>>t;
        while(t--)
        {
              ll n,k;
              cin>>n>>k;
              ll i;
              for(i=1;i<=n-1;i++)
              {
                  ll x,y;
                  cin>>x>>y;

                  adj[x].push_back(y);
                  adj[y].push_back(x);
              }
             dfs(0,1.0,0);
             printf("%.6f",res);
             cout<<res<<endl;
        }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define inf ((ll)1e18+1))
vector<ll>adj[200005];
vector<ll>vis(200005,0);
double res=0.0;
void dfs(ll v,double prob,ll depth)
{
    if(vis[v])
    return;
    vis[v]=1;
    ll c=0;
    for(auto i:adj[v])
    {
        if(!vis[i])
        c++;
    }
    for(auto i:adj[v])
    {
        if(!vis[i])
        dfs(i,prob/c,depth+1);
    }
    if(c==0)//LEAF NODE
    {
    res+=prob*depth;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    //cin>>t;
        while(t--)
        {
              ll n,k;
              cin>>n>>k;
              ll i;
              for(i=1;i<=n-1;i++)
              {
                  ll x,y;
                  cin>>x>>y;
                  x--;
                  y--;
                  adj[x].push_back(y);
                  adj[y].push_back(x);
              }
             dfs(0,1.0,0);
             cout<<fixed<<setprecision(7)<<res<<endl;
        }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define inf ((ll)1e18+1))
vector<ll>adj[200005];
vector<ll>vis(200005,0);
double res=0.0;
void dfs(ll v,double prob,ll depth)
{
    vis[v]=1;
    ll c=0;
    for(auto i:adj[v])
    {
        if(!vis[i])
        c++;
    }
    for(auto i:adj[v])
    {
        if(!vis[i])
        dfs(i,prob/c,depth+1);
    }
    if(c==0)//LEAF NODE
    {
    res+=prob*depth;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    //cin>>t;
        while(t--)
        {
              ll n,k;
              cin>>n>>k;
              ll i;
              for(i=1;i<=n-1;i++)
              {
                  ll x,y;
                  cin>>x>>y;
                  x--;
                  y--
                  adj[x].push_back(y);
                  adj[y].push_back(x);
              }
             dfs(0,1.0,0);
             printf("%.6f",res);
             cout<<res<<endl;
        }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define inf ((ll)1e18+1))
vector<ll>adj[200005];
vector<ll>vis(200005,0);
double res=0.0;
void dfs(ll v,double prob,ll depth)
{
    vis[v]=1;
    ll c=0;
    for(auto i:adj[v])
    {
        if(!vis[i])
        c++;
    }
    for(auto i:adj[v])
    {
        if(!vis[i])
        dfs(i,prob/c,depth+1);
    }
    if(c==0)//LEAF NODE
    {
    res+=prob*depth;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    //cin>>t;
        while(t--)
        {
              ll n,k;
              cin>>n>>k;
              ll i;
              for(i=1;i<=n-1;i++)
              {
                  ll x,y;
                  cin>>x>>y;
                  x--;
                  y--;
                  adj[x].push_back(y);
                  adj[y].push_back(x);
              }
             dfs(0,1.0,0);
             printf("%.6f",res);

        }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ldb;
typedef vector<ll> vll;

#define pb push_back
#define mpr make_pair
#define tc ll testcase; cin>>testcase; while(testcase--)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define l(x)                     cout <<"lol"<<x<<"\n";
#define trace1(x)                cout <<#x<<":"<<x<< endl;
#define trace2(x, y)             cout <<#x<<":"<<x<<" | "<<#y<<":"<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<":"<<x<<" | "<<#y<<":"<<y<<" | "<<#z<<":"<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<" | "<<#d<<":"<<d<<endl;

const ll mod = 1e9+7;
const ldb PI = acos(-1);

ll POWER[65];
void precompute() {POWER[0]=1; for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL; }
ll fastMul(ll a,ll b,ll mod){ll res = 0; a %= mod; while (b){   if (b & 1){res = (res + a) % mod;} a = (2 * a) % mod; b >>= 1;} return res;}
ll power(ll x,ll y,ll mod2) {ll res=1; x%=mod2; while(y) {if(y&1) res=fastMul(res,x,mod2); y>>=1; x=fastMul(x,x,mod2); }return res;}
ll inv(ll x,ll mod){return power(x,mod-2,mod);}

/*
    freopen("testfile.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
*/
double expe[100005];
vector<int> adj[100005];
double dfs(int cur,int p)
{
    expe[cur] = 0;
    int sz = 0;
    for(auto e:adj[cur])
    {
        if(e!=p)
        {
            dfs(e,cur);
            sz++;
        }
    }

    if(!sz)
    {
        expe[cur] = 0;
    }
    else
    {
        for(auto e:adj[cur])
        {
            if(e!=p)
            {
                expe[cur] += (1+expe[cur]);
            }
        }
        expe[cur] /= (1.0*sz);
    }
    return 0;
}

int main()
{
    fast_io();
    int n;
    cin >> n;

    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs(1,-1);
    printf("%0.6f",expe[1]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<long> Adj[100005];
bool vis[100005];
long long dist[100005];

void bfs(long a)
{
	queue<long> q;
	q.push(a);
	vis[a] = true;
	dist[a] = 0;

	while(!q.empty())
	{
		long d = q.front();
		q.pop();

		for(int i=0;i<Adj[d].size();i++)
		{
			if(!vis[Adj[d][i]])
			{
				vis[Adj[d][i]] = true;
				dist[Adj[d][i]] = dist[d] + 1;
				q.push(Adj[d][i]);
			}
		}
	}
}

int main()
{
	long long n,sum=0;
	cin >> n;
	vector<int> V;
	for(int i=1;i<n;i++)
	{
		long a,b;
		cin >> a >> b;

		Adj[a].push_back(b);
		Adj[b].push_back(a);
	}

	if(n == 1)
	{
		V.push_back(1);
	}
	else
	{
		for(int i=2;i<=n;i++)
		{
			if(Adj[i].size() == 1)
			{
				//cout << "i = " << i <<endl;
				V.push_back(i);
			}
		}
	}
	/*for(int i=0;i<n;i++)
	{
		for(int j=0;j<Adj[i].size();j++)
		{
			cout <<" Adj["<<i<<"]["<<j<<"] = "<< Adj[i][j] <<endl;
		}
	}		*/
	//cout <<"leaf nodes =" << V.size() <<endl;
	bfs(1);
	long long d1 = V.size();
	for(int j=0;j<d1;j++)
	{
		//cout << dist[V[j]]<<endl;
		sum += dist[V[j]];
	}

	//cout << "sum = " <<sum<<endl;
	printf("%.15f ", (double)sum/d1);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> Adj[100005];
bool vis[100005];
int dist[100005];

void bfs(int a)
{
	queue<int> q;
	q.push(a);
	vis[a] = true;
	dist[a] = 0;

	while(!q.empty())
	{
		int d = q.front();
		q.pop();

		for(int i=0;i<Adj[d].size();i++)
		{
			if(!vis[Adj[d][i]])
			{
				vis[Adj[d][i]] = true;
				dist[Adj[d][i]] = dist[d] + 1;
				q.push(Adj[d][i]);
			}
		}
	}
}

int main()
{
	long long n,sum=0;
	cin >> n;
	vector<int> V;
	for(int i=1;i<n;i++)
	{
		int a,b;
		cin >> a >> b;

		Adj[a].push_back(b);
	}

	for(int i=1;i<=n;i++)
	{
		if(Adj[i].size() == 0)
		{
			V.push_back(i);
		}
	}

	bfs(1);
	int d1 = V.size();
	for(int j=0;j<d1;j++)
	{
		sum += dist[V[j]];
	}

	printf("%.15f ", (double)sum/d1);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<long> Adj[100005];
bool vis[100005];
long long dist[100005];

void bfs(long a)
{
	queue<long> q;
	q.push(a);
	vis[a] = true;
	dist[a] = 0;

	while(!q.empty())
	{
		long d = q.front();
		q.pop();

		for(int i=0;i<Adj[d].size();i++)
		{
			if(!vis[Adj[d][i]])
			{
				vis[Adj[d][i]] = true;
				dist[Adj[d][i]] = dist[d] + 1;
				q.push(Adj[d][i]);
			}
		}
	}
}

int main()
{
	long long n,sum=0;
	cin >> n;
	vector<int> V;
	for(int i=1;i<n;i++)
	{
		long a,b;
		cin >> a >> b;

		Adj[a].push_back(b);
	}

	for(int i=1;i<=n;i++)
	{
		if(Adj[i].size() == 0)
		{
			//cout << "i = " << i <<endl;
			V.push_back(i);
		}
	}

	//cout <<"leaf nodes =" << V.size() <<endl;
	bfs(1);
	long long d1 = V.size();
	for(int j=0;j<d1;j++)
	{
		//cout << dist[V[j]]<<endl;
		sum += dist[V[j]];
	}

	//cout << "sum = " <<sum<<endl;
	printf("%.15f ", (double)sum/d1);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ldb;
typedef vector<ll> vll;

#define pb push_back
#define mpr make_pair
#define tc ll testcase; cin>>testcase; while(testcase--)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define l(x)                     cout <<"lol"<<x<<"\n";
#define trace1(x)                cout <<#x<<":"<<x<< endl;
#define trace2(x, y)             cout <<#x<<":"<<x<<" | "<<#y<<":"<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<":"<<x<<" | "<<#y<<":"<<y<<" | "<<#z<<":"<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<" | "<<#d<<":"<<d<<endl;

const ll mod = 1e9+7;
const ldb PI = acos(-1);

ll POWER[65];
void precompute() {POWER[0]=1; for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL; }
ll fastMul(ll a,ll b,ll mod){ll res = 0; a %= mod; while (b){   if (b & 1){res = (res + a) % mod;} a = (2 * a) % mod; b >>= 1;} return res;}
ll power(ll x,ll y,ll mod2) {ll res=1; x%=mod2; while(y) {if(y&1) res=fastMul(res,x,mod2); y>>=1; x=fastMul(x,x,mod2); }return res;}
ll inv(ll x,ll mod){return power(x,mod-2,mod);}

/*
    freopen("testfile.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
*/
double expe[100005];
vector<int> adj[100005];
double dfs(int cur,int p)
{
    expe[cur] = 0;
    int sz = 0;
    for(auto e:adj[cur])
    {
        if(e!=p)
        {
            dfs(e,cur);
            sz++;
        }
    }

    if(!sz)
    {
        expe[cur] = 0;
    }
    else
    {
        for(auto e:adj[cur])
        {
            if(e!=p)
            {
                expe[cur] += (1+dfs(e,cur));
            }
        }
        expe[cur] /= 1.0*sz;
    }
}

int main()
{
    fast_io();
    int n;
    cin >> n;

    for(int i=0;i<n-1;i++)
    {
        int u,v;
        u--;
        v--;
        cin >> u >> v;

        adj[u].push_back(v);
    }

    dfs(0,-1);
    printf("%0.9f",expe[0]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<long> Adj[100005];
bool vis[100005];
long long dist[100005];

void bfs(long a)
{
	queue<long> q;
	q.push(a);
	vis[a] = true;
	dist[a] = 0;

	while(!q.empty())
	{
		long d = q.front();
		q.pop();

		for(int i=0;i<Adj[d].size();i++)
		{
			if(!vis[Adj[d][i]])
			{
				vis[Adj[d][i]] = true;
				dist[Adj[d][i]] = dist[d] + 1;
				q.push(Adj[d][i]);
			}
		}
	}
}

int main()
{
	long long n,sum=0;
	cin >> n;
	vector<int> V;
	for(int i=1;i<n;i++)
	{
		long a,b;
		cin >> a >> b;

		Adj[a].push_back(b);
		Adj[b].push_back(a);
	}

	for(int j=2;j<=n;j++)
	{
		if(Adj[j].size() == 1)
		{
			V.push_back(j);
		}
	}
	if(Adj[1].size() == 0)
	{
		V.push_back(1);
	}
	/*
	if(n == 1)
	{
		V.push_back(1);
	}
	else
	{
		for(int i=2;i<=n;i++)
		{
			if(Adj[i].size() == 1)
			{
				//cout << "i = " << i <<endl;
				V.push_back(i);
			}
		}
	}
	/*for(int i=0;i<n;i++)
	{
		for(int j=0;j<Adj[i].size();j++)
		{
			cout <<" Adj["<<i<<"]["<<j<<"] = "<< Adj[i][j] <<endl;
		}
	}		*/
	//cout <<"leaf nodes =" << V.size() <<endl;
	bfs(1);
	long long d1 = V.size();
	for(int j=0;j<d1;j++)
	{
		//cout << dist[V[j]]<<endl;
		sum += dist[V[j]];
	}

	//cout << "sum = " <<sum<<endl;
	printf("%.15f ", (double)sum/d1);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ldb;
typedef vector<ll> vll;

#define pb push_back
#define mpr make_pair
#define tc ll testcase; cin>>testcase; while(testcase--)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define l(x)                     cout <<"lol"<<x<<"\n";
#define trace1(x)                cout <<#x<<":"<<x<< endl;
#define trace2(x, y)             cout <<#x<<":"<<x<<" | "<<#y<<":"<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<":"<<x<<" | "<<#y<<":"<<y<<" | "<<#z<<":"<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<" | "<<#d<<":"<<d<<endl;

const ll mod = 1e9+7;
const ldb PI = acos(-1);

ll POWER[65];
void precompute() {POWER[0]=1; for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL; }
ll fastMul(ll a,ll b,ll mod){ll res = 0; a %= mod; while (b){   if (b & 1){res = (res + a) % mod;} a = (2 * a) % mod; b >>= 1;} return res;}
ll power(ll x,ll y,ll mod2) {ll res=1; x%=mod2; while(y) {if(y&1) res=fastMul(res,x,mod2); y>>=1; x=fastMul(x,x,mod2); }return res;}
ll inv(ll x,ll mod){return power(x,mod-2,mod);}

/*
    freopen("testfile.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
*/
double expe[100005];
vector<int> adj[100005];
double dfs(int cur,int p)
{
    expe[cur] = 0;
    int sz = 0;
    for(auto e:adj[cur])
    {
        if(e!=p)
        {
            dfs(e,cur);
            sz++;
        }
    }

    if(!sz)
    {
        expe[cur] = 0;
    }
    else
    {
        for(auto e:adj[cur])
        {
            if(e!=p)
            {
                expe[cur] += (1+expe[e]);
            }
        }
        expe[cur] /= (1.0*sz);
    }
    return 0;
}

int main()
{
    fast_io();
    int n;
    cin >> n;

    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs(1,-1);
    printf("%0.6f",expe[1]);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ldb;
typedef vector<ll> vll;

#define pb push_back
#define mpr make_pair
#define tc ll testcase; cin>>testcase; while(testcase--)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define l(x)                     cout <<"lol"<<x<<"\n";
#define trace1(x)                cout <<#x<<":"<<x<< endl;
#define trace2(x, y)             cout <<#x<<":"<<x<<" | "<<#y<<":"<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<":"<<x<<" | "<<#y<<":"<<y<<" | "<<#z<<":"<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<" | "<<#d<<":"<<d<<endl;

const ll mod = 1e9+7;
const ldb PI = acos(-1);

ll POWER[65];
void precompute() {POWER[0]=1; for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL; }
ll fastMul(ll a,ll b,ll mod){ll res = 0; a %= mod; while (b){   if (b & 1){res = (res + a) % mod;} a = (2 * a) % mod; b >>= 1;} return res;}
ll power(ll x,ll y,ll mod2) {ll res=1; x%=mod2; while(y) {if(y&1) res=fastMul(res,x,mod2); y>>=1; x=fastMul(x,x,mod2); }return res;}
ll inv(ll x,ll mod){return power(x,mod-2,mod);}

/*
    freopen("testfile.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
*/
double expe[100005];
vector<int> adj[100005];
double dfs(int cur,int p)
{
    expe[cur] = 0;
    int sz = 0;
    for(auto e:adj[cur])
    {
        if(e!=p)
        {
            dfs(e,cur);
            sz++;
        }
    }

    if(!sz)
    {
        expe[cur] = 0;
    }
    else
    {
        for(auto e:adj[cur])
        {
            if(e!=p)
            {
                expe[cur] += (1+dfs(e,cur));
            }
        }
        expe[cur] /= 1.0*sz;
    }
}

int main()
{
    fast_io();
    int n;
    cin >> n;

    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin >> u >> v;
        u--;
        v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs(0,-1);
    printf("%0.9f",expe[0]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> Adj[100005];
bool vis[100005];
int dist[100005];

void bfs(int a)
{
	queue<int> q;
	q.push(a);
	vis[a] = true;
	dist[a] = 0;

	while(!q.empty())
	{
		int d = q.front();
		q.pop();

		for(int i=0;i<Adj[d].size();i++)
		{
			if(!vis[Adj[d][i]])
			{
				vis[Adj[d][i]] = true;
				dist[Adj[d][i]] = dist[d] + 1;
				q.push(Adj[d][i]);
			}
		}
	}
}

int main()
{
	long long n,sum=0;
	cin >> n;
	vector<int> V;
	for(int i=1;i<n;i++)
	{
		int a,b;
		cin >> a >> b;

		Adj[a].push_back(b);
	}

	for(int i=1;i<=n;i++)
	{
		if(Adj[i].size() == 0)
		{
			V.push_back(i);
		}
	}

	bfs(1);
	int d1 = V.size();

	printf("%.15f ", (double)sum/d1);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<long> Adj[100005];
bool vis[100005];
long long dist[100005];

void bfs(long a)
{
	queue<long> q;
	q.push(a);
	vis[a] = true;
	dist[a] = 0;

	while(!q.empty())
	{
		long d = q.front();
		q.pop();

		for(int i=0;i<Adj[d].size();i++)
		{
			if(!vis[Adj[d][i]])
			{
				vis[Adj[d][i]] = true;
				dist[Adj[d][i]] = dist[d] + 1;
				q.push(Adj[d][i]);
			}
		}
	}
}

int main()
{
	long long n,sum=0;
	cin >> n;
	vector<int> V;
	for(int i=1;i<n;i++)
	{
		long a,b;
		cin >> a >> b;

		Adj[a].push_back(b);
		Adj[b].push_back(a);
	}

	for(int i=1;i<=n;i++)
	{
		if(Adj[i].size() == 1)
		{
			//cout << "i = " << i <<endl;
			V.push_back(i);
		}
	}

	/*for(int i=0;i<n;i++)
	{
		for(int j=0;j<Adj[i].size();j++)
		{
			cout <<" Adj["<<i<<"]["<<j<<"] = "<< Adj[i][j] <<endl;
		}
	}		*/
	//cout <<"leaf nodes =" << V.size() <<endl;
	bfs(1);
	long long d1 = V.size();
	for(int j=0;j<=d1;j++)
	{
		//cout << dist[V[j]]<<endl;
		sum += dist[V[j]];
	}

	//cout << "sum = " <<sum<<endl;
	printf("%.15f ", (double)sum/d1);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<long> Adj[100005];
bool vis[100005];
long long dist[100005];

void bfs(long a)
{
	queue<long> q;
	q.push(a);
	vis[a] = true;
	dist[a] = 0;

	while(!q.empty())
	{
		long d = q.front();
		q.pop();

		for(int i=0;i<Adj[d].size();i++)
		{
			if(!vis[Adj[d][i]])
			{
				vis[Adj[d][i]] = true;
				dist[Adj[d][i]] = dist[d] + 1;
				q.push(Adj[d][i]);
			}
		}
	}
}

int main()
{
	long long n,sum=0;
	cin >> n;
	vector<int> V;
	for(int i=1;i<n;i++)
	{
		long a,b;
		cin >> a >> b;

		Adj[a].push_back(b);
		Adj[b].push_back(a);
	}

	for(int i=1;i<=n;i++)
	{
		if(Adj[i].size() == 1)
		{
			//cout << "i = " << i <<endl;
			V.push_back(i);
		}
	}

	/*for(int i=0;i<n;i++)
	{
		for(int j=0;j<Adj[i].size();j++)
		{
			cout <<" Adj["<<i<<"]["<<j<<"] = "<< Adj[i][j] <<endl;
		}
	}		*/
	//cout <<"leaf nodes =" << V.size() <<endl;
	bfs(1);
	long long d1 = V.size();
	for(int j=0;j<d1;j++)
	{
		//cout << dist[V[j]]<<endl;
		sum += dist[V[j]];
	}

	//cout << "sum = " <<sum<<endl;
	printf("%.15f ", (double)sum/d1);
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#define forn(i, min, max) for(int i = min; i < max; i++)

using namespace std;

vector<set<int>> ways;

long double dfs(int v, int l, int f = -1) {
	long double sum = 0;
	int k = 0;
	for (auto w : ways[v]) {
		if (w != f) {
			sum += dfs(w, l + 1, v);
			k++;
		}
	}
	if (k == 0) return l;
	return sum / k;
}

int main(){
	int n;
	scanf("%d",&n);
	ways.resize(n);
	forn(i, 1, n) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		ways[a].insert(b);
		ways[b].insert(a);
	}

	printf("%.6f", dfs(0, 0));

}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#define forn(i, min, max) for(int i = min; i < max; i++)

using namespace std;

vector<set<int>> ways;

long double dfs(int v, int l, int f = -1) {
	long double sum = 0;
	int k = 0;
	for (auto w : ways[v]) {
		if (w != f) {
			sum += dfs(w, l + 1, v);
			k++;
		}
	}
	if (k == 0) return l;
	return sum / k;
}

int main(){
	int n;
	cin >> n;
	ways.resize(n);
	forn(i, 1, n) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		ways[a].insert(b);
		ways[b].insert(a);
	}

	printf("%.6f", dfs(0, 0));

}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#define forn(i, min, max) for(int i = min; i < max; i++)

using namespace std;

vector<set<int>> ways;

long double dfs(int v, int l, int f = -1) {
	long double sum = 0;
	int k = 0;
	for (auto w : ways[v]) {
		if (w != f) {
			sum += dfs(w, l + 1, v);
			k++;
		}
	}
	if (k == 0) return l;
	return sum / k;
}

int main(){
	int n;
	cin >> n;
	ways.resize(n);
	forn(i, 1, n) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		ways[a].insert(b);
		ways[b].insert(a);
	}

	cout << dfs(0, 0);

}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#define forn(i, min, max) for(int i = min; i < max; i++)

using namespace std;

vector<set<int>> ways;

long double dfs(int v, int l, int f = -1) {
	long double sum = 0;
	int k = 0;
	for (auto w : ways[v]) {
		if (w != f) {
			sum += dfs(w, l + 1, v);
			k++;
		}
	}
	if (k == 0) return l;
	return sum / k;
}

int main(){
	int n;
	cin >> n;
	ways.resize(n);
	forn(i, 1, n) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		ways[a].insert(b);
	}

	cout << dfs(0, 0);

}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<iomanip>
#define forn(i, min, max) for(int i = min; i < max; i++)

using namespace std;

vector<set<int>> ways;

long double dfs(int v, int l, int f = -1) {
	long double sum = 0;
	int k = 0;
	for (auto w : ways[v]) {
		if (w != f) {
			sum += dfs(w, l + 1, v);
			k++;
		}
	}
	if (k == 0) return l;
	return sum / k;
}

int main(){
	int n;
	cin >> n;
	ways.resize(n);
	forn(i, 1, n) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		ways[a].insert(b);
		ways[b].insert(a);
	}

	cout << setprecision(6) << dfs(0, 0);

}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#define forn(i, min, max) for(int i = min; i < max; i++)

using namespace std;

vector<set<int>> ways;

long double dfs(int v, int l, int f = -1) {
	long double sum = 0;
	int k = 0;
	for (auto w : ways[v]) {
		if (w != f) {
			sum += dfs(w, l + 1, v);
			k++;
		}
	}
	if (k == 0) return l;
	return sum / k;
}

int main(){
	int n;
	cin >> n;
	ways.resize(n);
	forn(i, 1, n) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		ways[a].insert(b);
	}

	printf("%.6f", dfs(0, 0));

}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<iomanip>
#define forn(i, min, max) for(int i = min; i < max; i++)

using namespace std;

vector<set<int>> ways;

long double dfs(int v, int l, int f = -1) {
	long double sum = 0;
	int k = 0;
	for (auto w : ways[v]) {
		if (w != f) {
			sum += dfs(w, l + 1, v);
			k++;
		}
	}
	if (k == 0) return l;
	return sum / k;
}

int main(){
	int n;
	cin >> n;
	ways.resize(n);
	forn(i, 1, n) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		ways[a].insert(b);
		ways[b].insert(a);
	}

	cout << setprecision(10) << dfs(0, 0);

}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#define forn(i, min, max) for(int i = min; i < max; i++)

using namespace std;

vector<set<int>> ways;

long double dfs(int v, int l, int f = -1) {
	long double sum = 0;
	int k = 0;
	for (auto w : ways[v]) {
		if (w != f) {
			sum += dfs(w, l + 1, v);
			k++;
		}
	}
	if (k == 0) return l;
	return sum / k;
}

int main(){
	int n;
	cin >> n;
	ways.resize(n);
	forn(i, 1, n) {
		int a, b;
		n >> a >> b;
		a--; b--;
		ways[a].insert(b);
		ways[b].insert(a);
	}

	printf("%.6f", dfs(0, 0));

}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#define forn(i, min, max) for(int i = min; i < max; i++)

using namespace std;

vector<set<int>> ways;

long double dfs(int v, int l, int f = -1) {
	long double sum = 0;
	int k = 0;
	for (auto w : ways[v]) {
		if (w != f) {
			sum += dfs(w, l + 1, v);
			k++;
		}
	}
	if (k == 0) return l;
	return sum / k;
}

int main(){
	int n;
	cin >> n;
	ways.resize(n);
	forn(i, 1, n) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		ways[a].insert(b);
		ways[b].insert(a);
	}

	printf("%.6f", dfs(0, 0));

}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#define forn(i, min, max) for(int i = min; i < max; i++)

using namespace std;

vector<set<int>> ways;

double dfs(int v, int l, int f = -1) {
	double sum = 0;
	int k = 0;
	for (auto w : ways[v]) {
		if (w != f) {
			sum += dfs(w, l + 1, v);
			k++;
		}
	}
	if (k == 0) return l;
	return sum / k;
}

int main(){
	int n;
	cin >> n;
	ways.resize(n);
	forn(i, 1, n) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		ways[a].insert(b);
	}

	cout << dfs(0, 0);

}


#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 500000 + 10;

int p[MAX_N], a[MAX_N], b[MAX_N], c[MAX_N], seg[4*MAX_N];

int get(int id, int l, int r, int s, int e) {
    if (r <= s || l >= e)
        return 0;
    if (l >= s && r <= e)
        return seg[id];
    int mid = (l + r) / 2;
    return max(get(2*id+0, l, mid, s, e), get(2*id+1, mid, r, s, e));
}

void update(int id, int L, int R, int idx, int val){
    if (idx < L or R <= idx)
        return;
    if (L+1 == R){
        seg[id] = max(seg[id],val);
        return;
    }
    int mid = (L+R) >> 1;
    update(2*id+0, L, mid, idx, val);
    update(2*id+1, mid, R, idx, val);
    seg[id] = max(seg[2*id+0], seg[2*id+1]);
}

int main(){
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    for (int i = 0; i < n; i++)
        cin >> c[i];
    for (int i = 0; i < n; i++)
        p[i] = i;
    sort(p, p+n, [](int x, int y){
            if (a[x] != a[y])
            return a[x] < a[y];
            return b[x] > b[y];
            });
    vector<int> cmp;
    for (int i = 0; i < n; i++)
        cmp.push_back(b[i]);
    sort(cmp.begin(), cmp.end());
    cmp.resize(unique(cmp.begin(), cmp.end()) - cmp.begin()); //<-- ino goftan
    for (int i = 0; i < n; i++)
        b[i] = lower_bound(cmp.begin(), cmp.end(), b[i]) - cmp.begin();
    int answer = 0;
    for (int idx = n-1; idx >= 0; idx--){
        int i = p[idx];
        answer += (get(1, 0, n, b[i]+1, n) > c[i]);
        update(1, 0, n, b[i], c[i]);
    }
    cout << answer << '\n';
}


//#include <bits/stdc++.h>
//#include <ext/pb_ds/hash_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/rope>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <cassert>
#include <cmath>

#define X first
#define Y second
#define ls rt<<1
#define rs rt<<1|1
#define getmid ((l+r)>>1)
#define PB push_back
#define EP emplace_back
#define MP make_pair
#define lowbit(x) ((x)&-(x))
#define ALL(x) x.begin(),x.end()
#define mst(x,a) memset(x, a, sizeof(x))
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep1(i,n) for(int i=1; i<=(n); i++)
#ifdef LOCAL
    #define dbg(a) cout << #a": " << a << endl;
#else
    #define dbg(a)
#endif // LOCAL

using namespace std;
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
typedef double db;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;

const int N = 500000 + 10;
const int M = 4e4 + 10;
const int mod = 1000173169;
const double eps = 1e-10;
const double pi = acos(-1.0);

struct Node{
    int x,y,z;
    bool operator < (const Node& A) const {
        if(x^A.x) return x>A.x;
        if(y^A.y) return y<A.y;
        return z<A.z;
    }
} a[N];

int n;
int b[N],tot;
int mx[N<<2];

int query(int rt, int l, int r, int L, int R){
    if(L<=l && r<=R) return mx[rt];
    int mid = getmid;
    int res = -1;
    if(L<=mid) res = query(ls, l, mid, L, R);
    if(mid<R) res = max(res, query(rs, mid+1, r, L, R));
    return res;
}

void updata(int rt, int l, int r, int pos, int v){
    if(l==r) mx[rt] = max(mx[rt], v);
    else {
        int mid = getmid;
        if(pos<=mid) updata(ls, l, mid, pos, v);
        else updata(rs, mid+1, r, pos, v);
        mx[rt] = max(mx[ls], mx[rs]);
    }
}

int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
#endif // LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i].x;
    for(int i=1; i<=n; i++) cin>>a[i].y, b[++tot]=a[i].y;
    for(int i=1; i<=n; i++) cin>>a[i].z;
    sort(a+1, a+1+n);
    sort(b+1, b+1+tot);
    tot = unique(b+1, b+1+tot)-b-1;
    mst(mx, -1);
    int ans = 0;
    for(int i=1; i<=n; i++){
        a[i].y = lower_bound(b+1, b+1+tot, a[i].y)-b;
        int t = -1;
        if(a[i].y<tot) t = query(1, 1, tot, a[i].y+1, tot);
        if(t>a[i].z) ans++;
        updata(1, 1, tot, a[i].y, a[i].z);
    }
    cout<<ans<<'\n';

    return 0;
}


//#include <bits/stdc++.h>
//#include <ext/pb_ds/hash_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/rope>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <cassert>
#include <cmath>

#define X first
#define Y second
#define ls rt<<1
#define rs rt<<1|1
#define getmid ((l+r)>>1)
#define PB push_back
#define EP emplace_back
#define MP make_pair
#define lowbit(x) ((x)&-(x))
#define ALL(x) x.begin(),x.end()
#define mst(x,a) memset(x, a, sizeof(x))
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep1(i,n) for(int i=1; i<=(n); i++)
#ifdef LOCAL
    #define dbg(a) cout << #a": " << a << endl;
#else
    #define dbg(a)
#endif // LOCAL

using namespace std;
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
typedef double db;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;

const int N = 500000 + 10;
const int M = 4e4 + 10;
const int mod = 1000173169;
const double eps = 1e-10;
const double pi = acos(-1.0);

struct Node{
    int x,y,z;
    bool operator < (const Node& A) const {
        if(x^A.x) return x>A.x;
        if(y^A.y) return y<A.y;
        return z<A.z;
    }
} a[N];

int n;
int b[N],tot;
int mx[N<<2];

int query(int rt, int l, int r, int L, int R){
    if(L<=l && r<=R) return mx[rt];
    int mid = getmid;
    int res = -1;
    if(L<=mid) res = query(ls, l, mid, L, R);
    if(mid<R) res = max(res, query(rs, mid+1, r, L, R));
    return res;
}

void updata(int rt, int l, int r, int pos, int v){
    if(l==r) mx[rt] = max(mx[rt], v);
    else {
        int mid = getmid;
        if(pos<=mid) updata(ls, l, mid, pos, v);
        else updata(rs, mid+1, r, pos, v);
        mx[rt] = max(mx[ls], mx[rs]);
    }
}

int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
#endif // LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i].x;
    for(int i=1; i<=n; i++) cin>>a[i].y, b[++tot]=a[i].y;
    for(int i=1; i<=n; i++) cin>>a[i].z;
    sort(a+1, a+1+n);
    sort(b+1, b+1+tot);
    tot = unique(b+1, b+1+tot)-b-1;
    mst(mx, -1);
    int ans = 0;
    for(int i=1; i<=n; i++){
        int t = -1;
        if(a[i].y<tot) t = query(1, 1, tot, a[i].y+1, tot);
        if(t>a[i].z) ans++;
        updata(1, 1, n, a[i].y, a[i].z);
    }
    cout<<ans<<'\n';

    return 0;
}


//#include <bits/stdc++.h>
//#include <ext/pb_ds/hash_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/rope>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <cassert>
#include <cmath>

#define X first
#define Y second
#define ls rt<<1
#define rs rt<<1|1
#define getmid ((l+r)>>1)
#define PB push_back
#define EP emplace_back
#define MP make_pair
#define lowbit(x) ((x)&-(x))
#define ALL(x) x.begin(),x.end()
#define mst(x,a) memset(x, a, sizeof(x))
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep1(i,n) for(int i=1; i<=(n); i++)
#ifdef LOCAL
    #define dbg(a) cout << #a": " << a << endl;
#else
    #define dbg(a)
#endif // LOCAL

using namespace std;
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
typedef double db;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;

const int N = 500000 + 10;
const int M = 4e4 + 10;
const int mod = 1000173169;
const double eps = 1e-10;
const double pi = acos(-1.0);

struct Node{
    int x,y,z;
    bool operator < (const Node& A) const {
        if(x^A.x) return x>A.x;
        if(y^A.y) return y<A.y;
        return z<A.z;
    }
} a[N];

int n;
int b[N],tot;
int mx[N<<2];

int query(int rt, int l, int r, int L, int R){
    if(L<=l && r<=R) return mx[rt];
    int mid = getmid;
    int res = -1;
    if(L<=mid) res = query(ls, l, mid, L, R);
    if(mid<R) res = max(res, query(rs, mid+1, r, L, R));
    return res;
}

void updata(int rt, int l, int r, int pos, int v){
    if(l==r) mx[rt] = max(mx[rt], v);
    else {
        int mid = getmid;
        if(pos<=mid) updata(ls, l, mid, pos, v);
        else updata(rs, mid+1, r, pos, v);
        mx[rt] = max(mx[ls], mx[rs]);
    }
}

int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
#endif // LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i].x;
    for(int i=1; i<=n; i++) cin>>a[i].y, b[++tot]=a[i].y;
    for(int i=1; i<=n; i++) cin>>a[i].z;
    sort(a+1, a+1+n);
    sort(b+1, b+1+tot);
    tot = unique(b+1, b+1+tot)-b-1;
    mst(mx, -1);
    int ans = 0;
    for(int i=1; i<=n; i++){
        a[i].y = lower_bound(b+1, b+1+tot, a[i].y)-b;
        int t = -1;
        if(a[i].y<tot) t = query(1, 1, tot, a[i].y+1, tot);
        if(t>a[i].z) ans++;
        updata(1, 1, n, a[i].y, a[i].z);
    }
    cout<<ans<<'\n';

    return 0;
}


/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
/*
　　　　　／＞　 フ
　　　　　| 　_　 _|
　 　　　／`ミ _x 彡      КАК ЖЕ МНЕ НАДОЕЛА ЭТА ПРОГА ТУПАЯ ГОСПОДИ
　　 　 /　　　 　 |
　　　 /　  ヽ　　 ﾉ
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)_)
　＼二つ
 */

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
mt19937 gen(time(0));
bool IS_ONE_TEST = 1;
vector<int> t;
void update(int idx, int v, int val, int vl, int vr) {
    if (vl == vr)
        t[v] = max(t[v], val);
    else {
        int vm = (vl + vr) / 2;
        if (idx <= vm)
            update(idx, 2 * v + 1, val, vl, vm);
        else
            update(idx, 2 * v + 2, val, vm + 1, vr);
        t[v] = max(t[2 * v + 1], t[2 * v + 2]);
    }
}
int getmax(int v, int l, int r, int vl, int vr) {
    if (l <= vl && vr <= r)
        return t[v];
    if (l > vr || vl > r)
        return -1;
    int vm = (vl + vr) / 2;
    return max(getmax(2 * v + 1, l, r, vl, vm), getmax(2 * v + 2, l, r, vm + 1, vr));
}
void solve() {
    int n;
    cin >> n;
    set<int> a, b, c;
    map<int, int> toa, tob, toc;
    int na = 1, nb = 1, nc = 1;
    vector<int> va(n), vb(n), vc(n);
    vector<tuple<int, int, int>> q(n);
    for (int i = 0; i < n; ++i) {
        cin >> va[i];
        a.insert(va[i]);
    }
    for (int i = 0; i < n; ++i) {
        cin >> vb[i];
        b.insert(vb[i]);
    }
    for (int i = 0; i < n; ++i) {
        cin >> vc[i];
        c.insert(vc[i]);
    }
    for (auto &d : a)
        toa[d] = na++;
    for (auto &d : b)
        tob[d] = nb++;
    for (auto &d : c)
        toc[d] = nc++;
    for (int i = 0; i < n; ++i) {
        int x = va[i], y = vb[i], z = vc[i];
        q[i] = make_tuple(toa[x], tob[y], toc[z]);
    }
    sort(q.rbegin(), q.rend());
    //vector<int> maxes(n + 5);
    t.resize(4 * n + 20);
    int cnt = 0;
    for (int i = 0; i < q.size();) {
        int pi = i;
        for (int j = i; j < n; ++j) {
            if (get<0>(q[j]) != get<0>(q[i]))
                break;
            int cur_max = -1;
            //for (int z = get<1>(q[j]) + 1; z < n + 5; ++z)
            //    cur_max = max(cur_max, maxes[z]);
            cur_max = getmax(0, get<1>(q[j]) + 1, n + 4, 0, n);
            if (cur_max > get<2>(q[j]))
                ++cnt;
        }
        for (int j = i; j < n; ++j) {
            if (get<0>(q[j]) != get<0>(q[i])) {
                i = j;
                break;
            }
            //maxes[get<1>(q[j])] = max(maxes[get<1>(q[j])], get<2>(q[j]));
            update(get<1>(q[j]), 0, get<2>(q[j]), 0, n);
        }
        if (i == pi)
            break;
    }
    cout << cnt << endl;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    cout << fixed << setprecision(15);
    int t;
    if (IS_ONE_TEST)
        t = 1;
    else
        cin >> t;
    while (t-->0) {
        solve();
    }
}


/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
/*
　　　　　／＞　 フ
　　　　　| 　_　 _|
　 　　　／`ミ _x 彡      КАК ЖЕ МНЕ НАДОЕЛА ЭТА ПРОГА ТУПАЯ ГОСПОДИ
　　 　 /　　　 　 |
　　　 /　  ヽ　　 ﾉ
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)_)
　＼二つ
 */

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
mt19937 gen(time(0));
bool IS_ONE_TEST = 1;
void upd(int idx, int val, vector<int> &f) {
    for (; idx < f.size(); idx += (idx & (-idx)))
        f[idx] = max(f[idx], val);
}
int getmax(int idx, vector<int> &f) {
    int res = -1;
    for (; idx > 0; idx -= (idx & (-idx)))
        res = max(res, f[idx]);
    return res;
}
void solve() {
    int n;
    cin >> n;
    set<int> a, b, c;
    map<int, int> toa, tob, toc;
    int na = 1, nb = 1, nc = 1;
    vector<int> va(n), vb(n), vc(n);
    vector<tuple<int, int, int>> q(n);
    for (int i = 0; i < n; ++i) {
        cin >> va[i];
        a.insert(va[i]);
    }
    for (int i = 0; i < n; ++i) {
        cin >> vb[i];
        b.insert(vb[i]);
    }
    for (int i = 0; i < n; ++i) {
        cin >> vc[i];
        c.insert(vc[i]);
    }
    for (auto &d : a)
        toa[d] = na++;
    for (auto &d : b)
        tob[d] = nb++;
    for (auto &d : c)
        toc[d] = nc++;
    for (int i = 0; i < n; ++i) {
        int x = va[i], y = vb[i], z = vc[i];
        q[i] = make_tuple(toa[x], tob[y], toc[z]);
    }
    sort(q.rbegin(), q.rend());
    vector<int> maxes(n + 5);
    int cnt = 0;
    for (int i = 0; i < q.size();) {
        int pi = i;
        for (int j = i; j < n; ++j) {
            if (get<0>(q[j]) != get<0>(q[i]))
                break;
            int cur_max = -1;
            //for (int z = get<1>(q[j]) + 1; z < n + 5; ++z)
            //for (int z = 1; z <= n + 5 - (get<1>(q[j]) + 1); ++z)
            //    cur_max = max(cur_max, maxes[z]);
            cur_max = getmax(n + 5 - (get<1>(q[j]) + 1), maxes);
            if (cur_max > get<2>(q[j]))
                ++cnt;
        }
        for (int j = i; j < n; ++j) {
            if (get<0>(q[j]) != get<0>(q[i])) {
                i = j;
                break;
            }
            upd(n + 5 - get<1>(q[j]), get<2>(q[j]), maxes);
            //maxes[n + 5 - get<1>(q[j])] = max(maxes[n + 5 - get<1>(q[j])], get<2>(q[j]));
        }
        if (i == pi)
            break;
    }
    cout << cnt << endl;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << fixed << setprecision(15);
    int t;
    if (IS_ONE_TEST)
        t = 1;
    else
        cin >> t;
    while (t-->0) {
        solve();
    }
}


/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
/*
　　　　　／＞　 フ
　　　　　| 　_　 _|
　 　　　／`ミ _x 彡      КАК ЖЕ МНЕ НАДОЕЛА ЭТА ПРОГА ТУПАЯ ГОСПОДИ
　　 　 /　　　 　 |
　　　 /　  ヽ　　 ﾉ
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)_)
　＼二つ
 */

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
mt19937 gen(time(0));
bool IS_ONE_TEST = 1;
int n;
void upd(int idx, int val, unordered_map<int, int> &f) {
    for (; idx < n + 5; idx += (idx & (-idx)))
        f[idx] = max(f[idx], val);
}
int getmax(int idx, unordered_map<int, int> &f) {
    int res = -1;
    for (; idx > 0; idx -= (idx & (-idx)))
        res = max(res, f[idx]);
    return res;
}
void solve() {
    cin >> n;
    vector<int> B;
    map<int, int> tob;
    int na = 1, nb = 1, nc = 1;
    vector<int> va(n), vb(n), vc(n);
    vector<tuple<int, int, int>> q(n);
    for (int i = 0; i < n; ++i)
        cin >> va[i];
    for (int i = 0; i < n; ++i) {
        cin >> vb[i];
        B.push_back(vb[i]);
    }
    sort(B.begin(), B.end());
    B.erase(unique(B.begin(), B.end()), B.end());
    for (int i = 0; i < n; ++i)
        cin >> vc[i];
    for (auto &d : B)
        tob[d] = nb++;
    for (int i = 0; i < n; ++i)
        q[i] = make_tuple(va[i], tob[vb[i]], vc[i]);
    sort(q.rbegin(), q.rend());
    unordered_map<int, int> maxes(n + 5);
    int cnt = 0;
    for (int i = 0; i < q.size();) {
        int pi = i;
        for (int j = i; j < n; ++j) {
            if (get<0>(q[j]) != get<0>(q[i]))
                break;
            int cur_max = -1;
            cur_max = getmax(n + 5 - (get<1>(q[j]) + 1), maxes);
            if (cur_max > get<2>(q[j]))
                ++cnt;
        }
        for (int j = i; j < n; ++j) {
            if (get<0>(q[j]) != get<0>(q[i])) {
                i = j;
                break;
            }
            upd(n + 5 - get<1>(q[j]), get<2>(q[j]), maxes);
        }
        if (i == pi)
            break;
    }
    cout << cnt << endl;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << fixed << setprecision(15);
    int t;
    if (IS_ONE_TEST)
        t = 1;
    else
        cin >> t;
    while (t-->0) {
        solve();
    }
}