import java.util.Scanner

fun main(args: Array<String>){
    val scn = Scanner(System.`in`)
    val v = scn.nextLine().toLong()

    var result = (v / 500) * 1000

    result += 5 * ((v % 500) /5)

    print(result)

}