local str = io.read() local allsame = true local all480 = true local alleven = true local all50 = true local sum = 0 local first = tonumber(str:sub(1, 1)) local n = #str for i = 1, n do local a = tonumber(str:sub(i, i)) if a ~= first then allsame = false end if a % 4 ~= 0 then all480 = false end if a % 2 ~= 0 then alleven = false end if a % 5 ~= 0 then all50 = false end sum = sum + a end if allsame then print(str) else local ret = 1 if all480 then ret = ret * 4 elseif alleven then ret = ret * 2 end if all50 then ret = ret * 5 end if sum % 9 == 0 then ret = ret * 9 elseif sum % 3 == 0 then ret = ret * 3 end print(ret) end