""" """ import sys from sys import stdin lis = [6,2,5,5,5,4,5,6,4,7,6] def f(x): ret = 0 if x < 0: ret += 1 x *= -1 while x > 0: ret += lis[x % 10] x //= 10 return ret P,N = map(int,stdin.readline().split()) while not(4 <= P <= 6) and N > 0: P = f(P) N -= 1 print (P)