fun main(args: Array<String>){
    val x = readLine()!!.toInt()
    val value1 = x / 500
    val rem = x % 500
    val value2 = rem / 5
    val result = value1 * 1000 + value2 * 5
    println(result)
}