mod is a oddball thingie, but anyways, this seems to work fine too:
Code:

Function b($)
do
If $+0=$
$b = '' + $ mod 2 + $b
$ = $ / 2
else
$b = 2*$b + left($,1)
$ = right($,~)
endif
Until $ = .
EndFunction



and the score is now 97