const Main = input => {
  const FH = 500
  const F = 5
  const property = parseInt(input)
  const count500 = Math.floor(property / FH)
  const amari = property % FH
  const count5 = Math.floor(amari / F)
  console.log(count500 * 1000 + count5 * 5)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));