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