P,N=input().split() if N=='0': print(P) exit() X=[6,2,5,5,4,5,6,4,7,6] def f(x): if x[0]=='-': return 1+f(x[1:]) r=0 for i in range(len(x)): r+=X[int(x[i])] return r if len(N)<=2: N=int(N) for i in range(N): P=str(f(P)) print(P) exit() for i in range(100): P=str(f(P)) print(P)