require 'jcode';$KCODE='u';m=["一","二","三","四","五","六","七","八","九","十","百","千"];while l=gets;a,p=0,nil;l.strip!.each_char{|c|;n=m.index c;if n>=9;x=1;(n-8).times{x*=10};a+=(p||1)*x;p=nil;else;p=n+1;end;};a+=p if p;p a;end