local mfl, mce = math.floor, math.ceil local t = {6, 2, 5, 5, 4, 5, 6, 4, 7, 6} local p, n = io.read():match("(%-?%d+) (%d+)") if n == "0" then print(p) os.exit() end if 3 < #n then n = 1000 else n = tonumber(n) end local c = 0 if p:sub(1, 1) == "-" then c = 1 p = p:sub(2, #p) end for i = 1, #p do local v = p:byte(i) - 48 c = c + t[v + 1] end p = c n = n - 1 for i = 1, n do if p == 0 then p = t[1] else local c = 0 while 0 < p do local v = p % 10 c = c + t[v + 1] p = mfl(p / 10) end p = c end end print(p)