#include <iostream>
#include <string>
using namespace std;
main () {
// freopen ("input.txt", "r", stdin);
// freopen ("output.txt", "w", stdout);
string s, st="", sp="", sg="";
cin>>s;
int t=s.rfind('(',s.size()-1);
int p=s.find(')',t);
// cout<<t<<" "<<p;
while (t!=-1) {
s[t]='0';
p=s.find(')',t);
s[p]='0';
if (s[p+1]>=50 && s[p+1]<=57) {
st=""; sp=""; sg="";
for (int i=0; i<t; i++) {
st=st+s[i];
}
int so=s[p+1]-'0';
for (int i=1; i<=so; i++) {
for (int j=t+1; j<p; j++) {
sg=sg+s[j];
}
}
for (int i=p+2; i<s.size(); i++) {
sp=sp+s[i];
}
s=st+sg+sp;
}
t=s.rfind('(',s.size()-1);
}
int tong=0;
for (int i=0; i<s.size(); i++) {
if (s[i]==67) {
tong=tong+12;
}
if (s[i]==72) {
tong=tong+1;
}
if (s[i]==79) {
tong=tong+16;
}
if (s[i]>=50 && s[i]<=57) {
int so=s[i]-'0';
if (s[i-1]==67) {
tong=tong+12*(so-1);
}
if (s[i-1]==72) {
tong=tong+1*(so-1);
}
if (s[i-1]==79) {
tong=tong+16*(so-1);
}
}
}
cout<<tong;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCiAKIAptYWluICgpIHsKLy8JZnJlb3BlbiAoImlucHV0LnR4dCIsICJyIiwgc3RkaW4pOwovLwlmcmVvcGVuICgib3V0cHV0LnR4dCIsICJ3Iiwgc3Rkb3V0KTsKCQoJc3RyaW5nIHMsIHN0PSIiLCBzcD0iIiwgc2c9IiI7CgljaW4+PnM7CglpbnQgdD1zLnJmaW5kKCcoJyxzLnNpemUoKS0xKTsKCWludCBwPXMuZmluZCgnKScsdCk7Ci8vCWNvdXQ8PHQ8PCIgIjw8cDsKIAogCgl3aGlsZSAodCE9LTEpIHsKCQkKCQlzW3RdPScwJzsKCQlwPXMuZmluZCgnKScsdCk7CgkJc1twXT0nMCc7CgkJ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