import java.io.PrintWriter
import java.util.StringTokenizer
import kotlin.math.max

fun main() {
    val reader = System.`in`.bufferedReader()
    val writer = PrintWriter(System.out, false)

    var tokenizer: StringTokenizer = StringTokenizer("")

    fun next(): String {
        while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
        return tokenizer.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextLine() = reader.readLine()

    fun PrintWriter.solve() {
        var k = nextInt()
        var xmax = k/500
        var ymax = k/5

        var ans = 0
        for (x in 0..xmax){

            var (l,r) = listOf(0,ymax)
            while (l <= r){
                var y = l + (r-l)/2
                var calc = 1000*x + 5*y
                if (calc <= 2*k && 500*x + 5*y <=k ){
                    ans = max(ans,calc)
                    l = y+1
                }
                else r = y-1

            }
        }

        println(ans)

    }

    writer.solve()
    writer.flush()


}


