#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <ctype.h>
/*
* === FUNCTION ======================================================================
* Name: main
* Description:
* =====================================================================================
*/
/*
* === FUNCTION ======================================================================
* Name: get_g
* Description:
* =====================================================================================
*/
float get_g ( char a )
{
switch(a){
case 'C':
return 12.01;
break;
case 'H':
return 1.008;
break;
case 'O':
return 16.00;
break;
case 'N':
return 14.01;
break;
default:
return -1.0;
}
}
int main ( int argc, char *argv[] ) {
char buf[101]={};
int flag = 0;
float sum = 0.0;
int i = 0 ;
int j = 0;
int count = 0;
while( (scanf("%s", buf)!=EOF) ){
flag = 0;
for (i = 0; buf[i]!='\0'; i++) {
count = 0;
for( j=i+1;isdigit(buf[j])&&buf[j];j++ ){
count = count * 10 + (buf[j]-'0');
}
if (count==0) {
count=1;
}
if (buf[i]!='C'
&& buf[i]!='N'
&& buf[i]!='O'
&& buf[i]!='H'
) {
flag = 1;
}
sum += count * get_g(buf[i]);
i=j-1;
}
if (!flag){
printf ( "sum is %f\n",sum );
}else{
// printf ( "input error\n" );
}
}
return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */