import Data.Char
main=print.solve.(\[n,k]->(n,read k)).lines=<<getContents
solve(n,k)=(!!k).fst.foldr f((\a->(a,a))$1:replicate k 0)$map digitToInt n
f i(rs,as)=case i of
  0->(rs,bs)
  i->(mul(i-1)as`add`(0:rs)`add`as,bs)
  where bs=as`add`mul 9 as
add=zipWith(+)
mul k as=0:map(*k)as