def solution(dartResult):
answer = 0 ; k = []
a = 0
num = [str(i) for i in range(11)]
for i in range(len(dartResult)):
if dartResult[i]=="S":
if dartResult[i-1]=='0':
if i>=2 and dartResult[i-2]=='1':
a = 10
else:
a = 0
else:
a = int(dartResult[i-1])
if i+1 <= len(dartResult)-1:
if dartResult[i+1] == "*":
if k != []:
k[-1] = k[-1]*2
a = (a*2)
elif dartResult[i+1] == "#":
a = (a*(-1))
k.append(a)
elif dartResult[i]=="D":
if dartResult[i-1]=='0':
if i>=2 and dartResult[i-2] in num:
a = 10
else:
a = 0
else:
a = int(dartResult[i-1])
if i+1 <= len(dartResult)-1:
if dartResult[i+1] == "*":
if k != []:
k[-1] = k[-1]*2
a = ((a**2)*2)
elif dartResult[i+1] == "#":
a = ((a**2)*(-1))
else:
a = a**2
else:
a = a**2
k.append(a)
elif dartResult[i]=="T":
if dartResult[i-1]=='0':
if i>=2 and dartResult[i-2] in num:
a = 10
else:
a = 0
else:
a = int(dartResult[i-1])
if i+1 <= len(dartResult)-1:
if dartResult[i+1] == "*":
if k != []:
k[-1] = k[-1]*2
a = ((a**3)*2)
elif dartResult[i+1] == "#":
a = ((a**3)*(-1))
else:
a = a**3
else:
a = a**3
k.append(a)
return sum(k)