
fun main(args: Array<String>) {
    val money = readLine()!!.toInt()

    var nowMoney = money
    var uresisa = nowMoney / 500 * 1000
    nowMoney -= nowMoney / 500 * 500
    uresisa += nowMoney / 5 * 5
    println(uresisa)
}
