s[9];char*p;main(n,x){for(;gets(p=s);printf("%d\n",n+x))for(x=n=0;*p++;p++)x=*p++%12+7?"013 802"[-*p%19]:!(n+=(x+!x)*(*p%5?*p%6?10:100:1000));}