import qualified Data.Set as S
import qualified Data.List as L


toInt x = read x :: Int
toFloat x = read x :: Float

func :: Float -> Float -> Int -> Float
func b x = xb - fromIntegral (floor xb)
     where
          xb = (fromIntegral x) / b

main = do
     abn <- map toInt . words <$> getLine
     let a = fromIntegral $ head abn
         b = fromIntegral $ abn !! 1
         n = last abn
     print $ floor $ (*) a $ S.findMax $ S.map (func b) $ S.fromList [1..n]