l = [6, 2, 5, 5, 4, 5, 6, 4, 7, 6] [p, n] = map(int, input().split()) def f(p): x = 0 if p == 0: return l[0] if p < 0: p = -p x += 1 q = p while q > 0: x += l[q % 10] q //= 10 return x prev = p + 1 while n > 0 and p != prev: prev = p p = f(p) n -= 1 print(p)