money = int(input())

gohyakuen = money // 500

goen = (money-(gohyakuen*500)) // 5

happy = 1000 * gohyakuen + 5 * goen

print(happy)

25d211ab3b9069fe05bc50f021039017259b9754
<mask token>

<mask token>
print(happy)

money = int(input())
gohyakuen = money // 500
goen = (money - gohyakuen * 500) // 5
happy = 1000 * gohyakuen + 5 * goen
print(happy)

money = int(input())

gohyakuen = money // 500

goen = (money-(gohyakuen*500)) // 5

happy = 1000 * gohyakuen + 5 * goen

print(happy)
