# give up
n = int(input())
k = int(input())
digit = len(str(n))
s,m =  divmod(n,10**(digit-1))
print(s,m)
if k == 1:
    ans = (digit-1)*9 + s
if k == 2:
    ans = (digit-1)*9 * (s-1) + m
if k == 3:
    ans = 0 
print(ans)