D = [6,2,5,5,4,5,6,4,7,6] def f(x): if 0 <= x and x < 10: return D[x] if 10 <= x: r = 0 s = str(x) for i in s: r += f(int(i)) return r return 1 + f(-x) P,N = list(map(int,input().split())) #想定WA解法 N = min(5,N) ans = P for i in range(N): ans = f(ans) print(ans)