$l=length($S=<>)-1;$S=~s/.*/$&$&/; $_=substr($S,$_,$l),/^\D|\D$/||(s/\b0+\B//g,$%+=$-=(eval)-$%)for 0..$l-1; print$%