#include<map>
#include<stack>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
struct Node{
string s;
int cnt;
};
map<string,int> mp;
string s;
stack<Node> st;
int sum = 0;
void clear(){
mp["H"] = 10;
mp["C"] = 120;
mp["N"] = 140;
mp["O"] = 160;
mp["F"] = 190;
mp["Na"] = 230;
mp["Mg"] = 240;
mp["Al"] = 270;
mp["Si"] = 280;
mp["P"] = 310;
mp["S"] = 320;
mp["Cl"] = 355;
mp["K"] = 390;
mp["Ca"] = 400;
mp["Mn"] = 550;
mp["Fe"] = 560;
mp["Cu"] = 640;
mp["Zn"] = 650;
mp["Ag"] = 1080;
mp["I"] = 1270;
mp["Ba"] = 1370;
mp["Hf"] = 1785;
mp["Pt"] = 1950;
mp["Au"] = 1970;
mp["Hg"] = 2010;
}
int main(){
clear();
cin >> s;
int n = s.size();
s = " " + s;
int l = s.find("~");
if(l == -1) l = s.size();
for(int i = 1;i <= l;++i){
if(s[i] == '(') st.push({"(",0});
else if(s[i] == ')'){
if(s[i + 1] == '_'){
int j = i + 3,cnt = 0;
while(isdigit(s[j])) cnt = cnt * 10 + s[j++] - '0';
st.push({")",cnt});
i = j - 1;
}
else st.push({")",1});
}
else if(isupper(s[i])){
string t = "";
t += s[i];
int j = i + 1;
if(islower(s[j])) t += s[j++];
if(j > l){
st.push({t,1});
continue;
}
if(s[j] == '_'){
int cnt = 0,x = j + 2;
while(isdigit(s[x])) cnt = cnt * 10 + s[x++] - '0';
i = x - 1;
st.push({t,cnt});
}
else st.push({t,1});
}
}
int pos = l + 1,cnt = 0;
while(isdigit(s[pos])) cnt = cnt * 10 + s[pos++] - '0';
if(cnt == 0 && int(s.find("H_{2}O")) != -1) cnt = 1;
while(!st.empty()){
Node t = st.top();
st.pop();
if(t.s != ")") sum += mp[t.s] * t.cnt;
else{
int u = 0,k = t.cnt;
while(!st.empty() && st.top().s != "("){
u += mp[st.top().s] * st.top().cnt;
st.pop();
}
sum += u * k;
st.pop();
}
}
sum += cnt * 180;
if(sum % 10 != 0) printf("%.1lf\n",sum * 0.1);
else cout << sum / 10 << endl;
return 0;
}