L = [6, 2, 5, 5, 4, 5, 6, 4, 7, 6] def f(X): v = 0 for x in X: if x == "-": v += 1 else: v += L[int(x)] return str(v) P, N = input().split() if len(N) >= 3: N = 100 else: N = int(N) for _ in range(N): P = f(P) print(P)