Dreamoon is standing at the position 0 on a number line. Drazil is sending a list of commands through Wi-Fi to Dreamoon's smartphone and Dreamoon follows them.

Each command is one of the following two types:   Go 1 unit towards the positive direction, denoted as '+'  Go 1 unit towards the negative direction, denoted as '-' 

But the Wi-Fi condition is so poor that Dreamoon's smartphone reports some of the commands can't be recognized and Dreamoon knows that some of them might even be wrong though successfully recognized. Dreamoon decides to follow every recognized command and toss a fair coin to decide those unrecognized ones (that means, he moves to the 1 unit to the negative or positive direction with the same probability 0.5). 

You are given an original list of commands sent by Drazil and list received by Dreamoon. What is the probability that Dreamoon ends in the position originally supposed to be final by Drazil's commands?


-----Input-----

The first line contains a string s_1 — the commands Drazil sends to Dreamoon, this string consists of only the characters in the set {'+', '-'}. 

The second line contains a string s_2 — the commands Dreamoon's smartphone recognizes, this string consists of only the characters in the set {'+', '-', '?'}. '?' denotes an unrecognized command.

Lengths of two strings are equal and do not exceed 10.


-----Output-----

Output a single real number corresponding to the probability. The answer will be considered correct if its relative or absolute error doesn't exceed 10^{ - 9}.


-----Examples-----
Input
++-+-
+-+-+

Output
1.000000000000

Input
+-+-
+-??

Output
0.500000000000

Input
+++
??-

Output
0.000000000000



-----Note-----

For the first sample, both s_1 and s_2 will lead Dreamoon to finish at the same position  + 1. 

For the second sample, s_1 will lead Dreamoon to finish at position 0, while there are four possibilites for s_2: {"+-++", "+-+-", "+--+", "+---"} with ending position {+2, 0, 0, -2} respectively. So there are 2 correct cases out of 4, so the probability of finishing at the correct position is 0.5. 

For the third sample, s_2 could only lead us to finish at positions {+1, -1, -3}, so the probability to finish at the correct position  + 3 is 0.

Difficulty: interview

Starter code:

Solutions:
s=input()
t=input()
a=0
b=0
c=0
for i in range(len(s)):
   if s[i]=='+':a+=1
   else:a-=1
for i in range(len(t)):
   if t[i]=='+':b+=1
   elif t[i]=='-':b-=1
   else:c+=1
x=a-b
d=0-c
y=0-1
for i in range(c+1):
   if d==x:y=i
   d+=2

def fact(n):
   w=1
   for i in range(n):
      w*=(i+1)
   return(w)
  
def parmi(k,n):
   w=1
   w*=fact(n)
   w//=fact(k)
   w//=fact(n-k)
   return(w)
   
def puiss(k,n):
   w=1
   for i in range(n):
      w*=k
   return(w)
   
if y==-1:print(0.0)
else:print(parmi(y,c)/puiss(2,c))




import itertools
a = input()
b = input()

ap = a.count('+')
am = a.count('-')
bp = b.count('+')
bm = b.count('-')
bq = b.count('?')


if bq == 0:
    if ap == bp:
        print(1.0)
    else:
        print(0.0)
else:
    mas = list(itertools.product('+-', repeat=bq))
    if ap >= bp and am >= bm:
        ap -= bp
        am -= bm
        count = 0
        for el in mas:
            tmp_s = "".join(el)
            if tmp_s.count('+') == ap and tmp_s.count('-') == am:
                count += 1
        print(count / len(mas))
    else:
        print(0.0)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import itertools


s1 = input()
s2 = input()

s1_p = s1.count('+')
s1_n = s1.count('-')

s2_p = s2.count('+')
s2_n = s2.count('-')
s2_q = s2.count('?')

correct_pos = s1_p - s1_n
drea_pos = s2_p - s2_n

diff_pos = correct_pos - drea_pos

if s2_q == 0:
    if diff_pos == 0:
        print(1.0)
    else:
        print(0.0)
else:
    #print("diff_pos = ", diff_pos)
    num = 0
    den = 0
    for c in itertools.product([1, -1], repeat=s2_q):
        if sum(c) == diff_pos:
           num += 1 
        den += 1
    print("{0:.10f}".format(float(num) / den))





import math

#input

s1=str(input())
s2=str(input())



#variables
sum1=0
sum2=0
steps=0


def prob(x,y):
	if x>y:
		return 0
	elif y==0:
		if x==0:
			return 1
		else:
			return 0
	else:
		return (prob(x-1,y-1)+prob(x+1,y-1))/2


#main
for i in range(len(s1)):
	if s1[i]=='+':
		sum1+=1
	if s1[i]=='-':
		sum1-=1
	if s2[i]=='+':
		sum2+=1
	if s2[i]=='-':
		sum2-=1
	if s2[i]=='?':
		steps+=1

end=sum2-sum1

print(prob(end,steps))

'''
Created on Oct 12, 2014

@author: Ismael
'''
from collections import Counter

from math import factorial,log,sqrt

def nbCombinations(r, n):
    return factorial(n) // factorial(r) // factorial(n-r)

s1 = input()
s2 = input()
counterS1 = Counter(s1)
counterS2 = Counter(s2)
if(counterS1 == counterS2):
    print("1.000000000000")
else:
    if('?' not in counterS2):
        print("0.000000000000")
    else:#there is at least one ? in s2
        nbPlusToMuch = counterS2['+']-counterS1['+']
        nbMinusToMuch = counterS2['-']-counterS1['-']
        if(nbPlusToMuch > 0 or nbMinusToMuch > 0):
            print("0.000000000000")
        else:
            if(nbPlusToMuch < 0):
                k = abs(nbPlusToMuch)
            else:
                k = abs(nbMinusToMuch)
            n = counterS2['?']
            print(nbCombinations(k, n)*(0.5**n))


# 272 D2 B

def factorial(n):
    i = 1
    for j in range(1,n+1):
        i *= j
    return i

def choose(n,r):
    return int(factorial(n)/factorial(r)/factorial(n-r))

l = list(input())
exp = 0
for i in range(len(l)):
    if l[i] == "+":
        exp += 1
    else:
        exp -= 1

l1 = list(input())
dis = 0
unrec = 0
for i in range(len(l1)):
    if l1[i] == "+":
        dis += 1
    elif l1[i] == "-":
        dis -= 1
    else:
        unrec += 1


if abs(exp - dis) > unrec:
    print(0)
elif unrec == 0:
    print(1)
else:
    print(choose(unrec,(abs(exp-dis)+int((unrec-abs(exp-dis))/2)))/2**unrec)


def fac(n):
    ret = 1
    for i in range(2, n):
        ret *= i
    return ret

def C(n, k):
    return fac(n) // fac(k) // fac(n - k)

def transform(s):
    res = 0
    for c in s:
        if c == '0':
            res += 1
        else:
            res -= 1
    return res

s1 = input().strip()
s2 = input().strip()

dx = sum([1 if c == '+' else -1 for c in s1])

u = 0
dx2 = 0
for c in s2:
    if c == '?':
        u += 1
    else:
        dx2 += 1 if c == '+' else -1
if u == 0:
    if dx == dx2:
        print(1)
    else:
        print(0)
else:
    if (abs(dx - dx2) > u):
        print(0)
    else:
        d = abs(dx - dx2)
        well = 0
        for i in range(1 << u):
            if transform(bin(i)[2:].rjust(u, '0')) == d:
                well += 1
        print(well / (1 << u))


import math

def nCr(n,r):
    f = math.factorial
    return f(n) / f(r) / f(n-r)

x=input()
plus = x.count('+')
minus = x.count('-')
x=input()
plus_ = x.count('+')
minus_ = x.count('-')
n=x.count('?')
a=plus-plus_
b=minus-minus_
if(a<0 or b<0 or a+b!=n):
    print(0.0)
else:
    print(nCr(n,a)/(1<<n))

__author__ = 'neki'

import sys

#sys.stdin = open("wifi.in", "r")

def outcome(command):
    pos = 0
    for i in command:
        if i == "+": pos += 1
        elif i == "-": pos -= 1
        else: print("Error")
    return pos

def computeFinishes(k):
    nonlocal finish, recCommand, xCom, nSol

    if k >= len(xCom): #solution
        nSol += 1
        #print(k)
        solCom = recCommand[:]
        for i in range(len(xCom)):
            if xCom[i] == 1:
                solCom[i] = "+"
            if xCom[i] == 2:
                solCom[i] = "-"
        #print(xCom)
        #print(solCom)
        finish[outcome(solCom)] += 1
        return
    if recCommand[k] == "?":
        for j in range(1, 3):
            xCom[k] = j
            computeFinishes(k+1)
    else:
        computeFinishes(k+1)
    xCom[k] = 0

sentCommand1 = str(input())
recCommand1 = str(input())

sentCommand = ["A"] * len(sentCommand1)
recCommand = ["B"] * len(recCommand1)

for i in range(len(sentCommand1)):
    sentCommand[i] = sentCommand1[i]
    recCommand[i] = recCommand1[i]

#print(sentCommand)
#print(recCommand)

#print("Solutions")
sentFinish = outcome(sentCommand)
finish = {}
for i in range(-10, 11):
    finish[i] = 0

xCom = [0] * len(recCommand)

nSol = 0
computeFinishes(0)
result = finish[sentFinish] / nSol

print("{result:.12f}".format(result=result))


from itertools import chain

line = input()
p = line.count('+') - line.count('-')
d = [0]
for c in input():
	if c == '-':
		d = [x - 1 for x in d]
	elif c == '+':
		d = [x + 1 for x in d]
	else:
		d = list(chain.from_iterable((x + 1, x - 1) for x in d))
print(round(d.count(p) / len(d), 9))


import sys
import math
import os


data1=input()
data2=input()

a,b=0,0
c,d=0,0
vprs=0

for i in range (len(data1)):
    if data1[i]=='+':
        a+=1
    else:
        b+=1


for i in range(len(data2)):
    if data2[i]=='+':
        c+=1
    elif data2[i]=='-':
        d+=1
    else:
        vprs+=1

if vprs==0:
    if a==c and b==d:
        print("%.9f" % 1)
        #print(1.000000000)
    else:
       # print(0.000000000)
        print("%.9f" % 0)
else:
    if c>a or d>b:
        #print(0.000000000)
         print("%.9f" % 0)
    else:
        deltaM=a-c
        deltaP=b-d
        total=2**vprs
        fak1=1
        fak2=1
        fak3=1
      #  print(deltaM,deltaP)
        for i in range(1,vprs+1):
            fak1*=i
        for i in range(1,deltaM+1):
            fak2*=i
        for i in range(1,deltaP+1):
            fak3*=i
        #print(total)
        #print((fak1/fak2)/total)
        ans=(fak1/(fak2*fak3))/total
       # print(fak1,fak2,fak3)
        print("%.9f" % ans)

def main():
    str1 = input()
    str2 = input()
    poz_real = 0
    for i in range(len(str1)):
        if str1[i] == '+':
            poz_real += 1
        else:
            poz_real -= 1
    poz = [0]
    lent = 1
    for i in range(len(str2)):
        if str2[i] == '+':
            for j in range(len(poz)):
                poz[j] += 1
        if str2[i] == '-':
            for j in range(len(poz)):
                poz[j] -= 1
        if str2[i] == '?':
            for j in range(len(poz) - int(lent), len(poz)):
                poz.append(poz[j] - 1)
                poz.append(poz[j] + 1)
            lent *= 2
    count_sovp = 0
    was = []
    for i in range(len(poz) - int(lent), len(poz)):
        if poz[i] == poz_real:
            count_sovp += 1
    print(float(count_sovp/lent))

def __starting_point():
    main()

__starting_point()

fact = [1.0, 1.0,2.0,6.0, 24.0, 120.0, 720.0, 5040.0, 40320.0, 362880.0, 3628800.0]
s = input()
s1 = input()
k, k1, kv = 0, 0, 0
for c in s:
	if c == '+':
		k += 1
	else:
		k -= 1
for c in s1:
	if c == '+':
		k1 += 1
	if c == '-':
		k1 -= 1
	if c == '?':
		kv += 1

d = k - k1
if d < 0:
	d = -d
if (d > kv) or ((d % 2) and not(kv % 2)):
	print(0.0)
else:
	if (d == 0) and (kv == 0):
		print(1.0)
	else:
		print(fact[kv] / fact[int((kv - d) / 2)] / fact[kv - int((kv - d) / 2)] / (2.0**kv))

#!/usr/bin/env python
# -*- coding:utf-8 -*-

import itertools

def main():
    send = input()
    recv = input()

    pos = 0
    for c in send:
        if c == '+':
            pos += 1
        else:
            pos -= 1

    est = 0
    amb = 0
    for c in recv:
        if c == '+':
            est += 1
        elif c == '-':
            est -= 1
        else:
            amb += 1

    remain = pos - est

    prob = 0.0
    if amb == 0:
        if remain == 0:
            prob = 1.0
        else:
            prob = 0.0
    else:
        num = 0
        den = 0
        for seq in itertools.product( ( '+', '-' ), repeat = amb ):
            den += 1
            val = 0
            for c in seq:
                if c == '+':
                    val += 1
                else:
                    val -= 1

            if val == remain:
                num += 1

        prob = num / den

    print( prob )

    return

def __starting_point():
    main()

__starting_point()

def chng(c):
    return -1 if c == '-' else ( 1 if c == '+' else 0)

def f(z, d):
    if z == 0:
        nonlocal al
        al += 1
        if d == 0:
            nonlocal ne
            ne += 1
    else:
        f(z - 1, d - 1)
        f(z - 1, d + 1)
A = input()
B = input()
n = len(A)
x = 0
y = 0
z = 0
for i in range(n):
    x += chng(A[i])
    y += chng(B[i])
    if B[i] == '?':
        z += 1
if z == 0 and x == y:
    print(1)
else:
    d = abs(x - y)
    al = 0
    ne = 0
    f(z, d)
    print(ne / al)
#print(1 / (2 ** (z if z % 2 == 1 else z // 2)))


#fin = open("input.txt")
s = input()#fin.readline()
P, M = s.count("+"), s.count("-")
s = input()#fin.readline()
p, m = s.count("+"), s.count("-")
if (m > M or p > P):
	print(0)
else:
	r = P + M - (p + m)
	dp = [[0.0] * (r + 1) for i in range(r + 1)]
	dp[0][0] = 1
	for i in range(1, r + 1):
		for j in range(i + 1):
			#print(i, j)
			if j - 1 >= 0:
				#print(dp[i - j][j - 1])
				dp[i - j][j] += dp[i - j][j - 1] / 2
			if i - j - 1 >= 0:
				#print(dp[i - j - 1][j])
				dp[i - j][j] += dp[i - j - 1][j] / 2
	print(dp[P - p][M - m])


def ans(p, k):
    nonlocal d
    if k == n:
        d.append(p)
        return
    ans(p+1, k+1)
    ans(p-1, k+1)
    return

s1 = input()
s2 = input()
b = 0
k = 0
d = []

for i in s1:
    if i == '+':
        b+=1
    else:
        b-=1
for i in s2:
    if i == '+':
        b-=1
    elif i == '-':
        b+=1
    else:
        k+=1
        
n = k
ans(0,0)
#print(d)
s=0
for i in d:
    if i == b:
        s+=1

#c = (k-abs(b))/2
#print(c)
#g=f[k-1]/f[k-int(c)-1]/2
#print(g)
if b > k:
    print('%.9f' % 0)
elif b == k:
    print('%.9f' % (1/(2**(k))))
elif (k - b) % 2 == 0:
    print('%.9f' % (s/(2**(k))))
else:
    print('%.9f' % 0)

s1 = input()
s2 = input()
P = s1.count("+") - s1.count("-")
C = s2.count("+") - s2.count("-")
Goal = abs(P-C)
Cnt = s2.count("?")
K = [ [0]*21 for i in range(11)]
K[0][10] = 1.0
for i in range(1, Cnt+1) :
    for j in range(0, 21, 1) :
        if j-1 >= 0 :
            K[i][j] += K[i-1][j-1] * 0.5
        if j+1 <= 20 :
            K[i][j] += K[i-1][j+1] * 0.5
if Goal+10 <= 20 : print(K[Cnt][Goal+10])
else : print(0.0)


'''
Created on Oct 12, 2014

@author: Ismael
'''
from collections import Counter

from math import factorial

def nbCombinations(r, n):
    return factorial(n) // factorial(r) // factorial(n-r)

s1 = input()
s2 = input()
counterS1 = Counter(s1)
counterS2 = Counter(s2)
if(counterS1 == counterS2):
    print("1.000000000000")
else:
    if('?' not in counterS2):
        print("0.000000000000")
    else:#there is at least one ? in s2
        nbPlusToMuch = counterS2['+']-counterS1['+']
        nbMinusToMuch = counterS2['-']-counterS1['-']
        if(nbPlusToMuch > 0 or nbMinusToMuch > 0):
            print("0.000000000000")
        else:
            if(nbPlusToMuch < 0):
                k = abs(nbPlusToMuch)
            else:
                k = abs(nbMinusToMuch)
            n = counterS2['?']
            print(nbCombinations(k, n)*(0.5**n))


from math import factorial

s1, s2 = input().strip(), input().strip()
d, q = abs(s1.count('+') - s1.count('-') - s2.count('+') + s2.count('-')), s2.count('?')
print(0 if ((d + q) & 1 or d > q) else factorial(q) / factorial((d + q) >> 1) / factorial((q - d) >> 1) / (1 << q))


a = input()
b = input()

def foo(b, i, pos, poss):
    if i == len(b):
        poss.append(pos)
    elif b[i] == '+':
        foo(b,i+1,pos+1, poss)
    elif b[i] == '-':
        foo(b,i+1,pos-1, poss)
    else:
        foo(b,i+1,pos+1, poss)
        foo(b,i+1,pos-1, poss)

pos0 = 0
for x in a:
    if x == '+':
        pos0+=1
    else:
        pos0-=1

q = 0
for x in b:
    if x == '?':
        q+=1

poss = []
res = 0
foo(b, 0, 0, poss)
for x in poss:
    if x == pos0:
        res+=1

print (res / 2 ** q)

from math import factorial
def C(n, k):
    return int(factorial(n)/factorial(k)/factorial(n-k))

str1 = input()
str2 = input()
pos1 = 0
pos2 = 0
need = 0
for i in str1:
    if i == '+':
        pos1 += 1
    else:
        pos1 -= 1
        
for i in str2:
    if i == '+':
        pos2 += 1
    elif i == '-':
        pos2 -= 1
    else:
        need += 1
        
diff = abs(pos1 - pos2)
if diff%2 != need%2:
    print(0)
else:
    if need == 0:
        if pos1 == pos2:
            print(1)
        else:
            print(0)
        
    elif diff > need:
        print(0)
    else:
        a = (need+diff) // 2
        print(C(need, a)/(2**need))


__author__ = 'hamed1soleimani'

correct = input()
received = input()

final = 0
for ch in correct:
    if ch == '+':
        final += 1
    else:
        final -= 1

directions = [0]

for ch in received:
    if ch == '+':
        for i in range(len(directions)):
            directions[i] += 1
    elif ch == '-':
        for i in range(len(directions)):
            directions[i] -= 1
    else:
        temp = list()
        for d in directions:
            temp.append(d + 1)
            temp.append(d - 1)
        directions = temp

finished = 0
for d in directions:
    if d == final:
        finished += 1

out = str(finished / len(directions))
out += ('0' * (14 - len(out)))
print(out)

s = input()
t = input()
a, b, c = 0, 0, 0
for item in s:
	if item == '+':
		a += 1
	else:
		a -= 1
for item in t:
	if item == '+':
		b += 1
	elif item == '-':
		b -= 1
	else:
		c += 1
if c < abs(a - b) or (c - abs(a - b)) % 2 == 1:
	print(0)
else:
	x = 0.5 ** c
	for i in range((c - abs(a - b)) // 2):
		x *= c - i
		x /= 1 + i
	print(x)

from math import factorial as f

def main():
	a=input()
	b=input()
	ap=a.count('+')
	an=a.count('-')
	bp=b.count('+')
	bn=b.count('-')
	tandatanya=b.count('?')
	if tandatanya == 0:
		if ap-an != bp-bn:
			print ("%.9f" % (0))
		else:
			print ("%.9f" % (1))
		return
	probab=float(1/pow(2,tandatanya))
	x=(ap-an-(bp-bn)+tandatanya)//2
	y=tandatanya-x
	if x < 0 or y < 0:
		print ("%.9f" % (0))
		return
	probab*=f(tandatanya)/(f(x)*f(y))  
	print ("%.9f" % (probab))

main()