Imports System.Text
Imports System.String
Imports System
Imports System.Math

Module Module1

    Sub Main()
        Dim ans As String = ""
        Dim input As Long = CInt(Console.ReadLine)

        Dim fivehundred As Integer = CInt(Math.Floor(input / 500))
        Dim fiveyens As Integer = CInt(Math.Floor(CInt(input Mod 500) / 5))

        Console.WriteLine((fivehundred * 1000) + (fiveyens * 5))

        Console.ReadKey()
    End Sub


End Module