fun main(args: Array<String>) {
    val line = readLine()!!.trim()
    val amount: Long = line.toLong()

    val count500: Long = amount / 500L
    val amari500: Long = amount % 500L
    val count5: Long = amari500 / 5L

    val uresisa: Long = count500 * 1000L + count5 * 5L

    println(uresisa)
}