import sys input = sys.stdin.readline sys.setrecursionlimit(10**5) P,N=map(int,input().split()) def f(x): if x in {0,6,9}: return 6 if x==1: return 2 if x in {2,3,5}: return 5 if x in {4,7}: return 4 if x==8: return 7 if x>=10: return f(x//10)+f(x%10) if x<0: return 1+f(-x) for i in range(min(N,100)): P=f(P) print(P)