($n,$k)=glob<>; --$k; while($a=0 .chop$n){ ++$a; $_=$k%$a.$_; $k/=$a; } s/0*//;print$_||0;