print((function (f, g) return tostring(f(g(),g(),g())):sub(1,-3) end)(function (a, b, c) if a<=c then local d=a+b-1 return tostring(c/d*a+(c%d