Module Module1


    Sub Main()

        Dim sInput As Integer
        sInput = Console.ReadLine()
        Dim sExpect1000 As Integer = sInput \ 500
        Dim sExpect5 As Integer = (sInput Mod 500) \ 5
        Console.WriteLine(sExpect1000 * 1000 + sExpect5 * 5)
        Console.ReadLine()
    End Sub

End Module
