main = print =<< solve <$> getLineAsInt

getLineAsInt :: IO Int
getLineAsInt = read <$> getLine

solve :: Int -> Int
solve x =
    let (div500, mod500) = divMod x 500
        div5 = mod500 `div` 5
    in div500 * 1000 + div5 * 5