local numstr = io.read() local a, b, c = 0, 0, 0 for i = 1, #numstr do local s = numstr:sub(i, i) if(s == "0" or s == "4" or s == "6" or s == "9") then b = b + 1 elseif(s == "8") then c = c + 1 else a = a + 1 end end print(math.min(2*a+3*b+4*c+1, a+3*b+5*1+2))