$_+=<>;$s+=$a%10>3until++$a>30|$a*3>$_;$s+=$&/3<<2*length,$&%3&&y//9/cwhile s/.//;print$s-3