#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;
int solution(string dartResult) {
int answer = 0;
vector<int> v(3,0);
char ch;
for(int i=0,idx=0;i<dartResult.length();i++)
{
ch = dartResult[i];
if(isdigit(ch))
{
v[idx]=ch-'0';
if(dartResult[i+1] == '0') {
i++;
v[idx]=10;
}
}else if(ch == 'S' || ch == 'D' || ch == 'T'){
int mul = 1;
if(ch == 'D') mul=2;
if(ch == 'T') mul=3;
v[idx] = pow(v[idx],mul);
}else if(ch == '*'){
if(idx != 0) v[idx-1] *= 2;
v[idx] *= 2;
}else if(ch == '#'){
v[idx] *= -1;
}
if(isdigit(dartResult[i+1])){
idx++;
}
}
return answer = accumulate(v.begin(), v.end(), 0);
}