a = [6, 2, 5, 5, 4, 5, 6, 4, 7, 6] p, n = map(int, input().split()) if n == 0: print(p) exit(0) if p < 0: n -= 1 p = -p + 1 sg = 1 for i in range(min(n, 100)): res = 0 for c in str(p): res += a[ord(c) - ord('0')] p = res print(res)