
Module Module1
    Sub main()
        Dim user1 = Console.ReadLine()
        'Dim user1 = 1000000000

        Dim fiveMil As Long = Math.Floor(CLng(user1) / 500)
        user1 = user1 Mod 500
        Dim fiveCoin As Long = Math.Floor(CLng(user1) / 5)

        Console.WriteLine(fiveMil * 1000 + fiveCoin * 5)
    End Sub
end module