p, n = map(int, input().split()) def f(x): if x == 0: return 6 if x == 1: return 2 if x == 2: return 5 if x == 3: return 5 if x == 7: return 4 if x == 8: return 7 if x == 9: return 6 return x for i in range(min(5000, n)): newp = 0 if p < 0: newp += 1 p *= -1 s = str(p) for c in s: newp += f(int(c)) p = newp print(p)