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