print((function (f, fh) local r=0 for _=1,5 do r=r+f(fh:read("*n")) end return r end)(function (n) return n%15==0 and 8 or (n%3==0 or n%5==0) and 4 or #tostring(n) end, io.stdin))