import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int input = sc.nextInt();

        int fivehundreds = input / 500;

        int fivehundredrem = input % 500;

        int fives = fivehundredrem / 5;

        System.out.println(fivehundreds * 1000 + fives * 5);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int input = sc.nextInt();

        int fivehundreds = input / 500;

        int fivehundredrem = input % 500;

        int fives = fivehundredrem / 5;

        System.out.println(fivehundreds * 1000 + fives * 5);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int input = sc.nextInt();

        int fivehundreds = input / 500;

        int fivehundredrem = input % 500;

        int fives = fivehundredrem / 5;

        System.out.println(fivehundreds * 1000 + fives * 5);
    } main {
        Scanner sc = new Scanner(System.in);

        int input = sc.nextInt();

        int fivehundreds = input / 500;

        int fivehundredrem = input % 500;

        int fives = fivehundredrem / 5;

        System.out.println(fivehundreds * 1000 + fives * 5);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int input = sc.nextInt(); input sc.nextInt() sc.nextInt sc int fivehundreds = input / 500; fivehundreds input / 500 input 500 int fivehundredrem = input % 500; fivehundredrem input % 500 input 500 int fives = fivehundredrem / 5; fives fivehundredrem / 5 fivehundredrem 5 System.out.println(fivehundreds * 1000 + fives * 5) System.out.println System.out System System.out fivehundreds * 1000 + fives * 5 fivehundreds * 1000 fivehundreds 1000 fives * 5 fives 5 String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int input = sc.nextInt();

        int fivehundreds = input / 500;

        int fivehundredrem = input % 500;

        int fives = fivehundredrem / 5;

        System.out.println(fivehundreds * 1000 + fives * 5);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int input = sc.nextInt();

        int fivehundreds = input / 500;

        int fivehundredrem = input % 500;

        int fives = fivehundredrem / 5;

        System.out.println(fivehundreds * 1000 + fives * 5);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int input = sc.nextInt();

        int fivehundreds = input / 500;

        int fivehundredrem = input % 500;

        int fives = fivehundredrem / 5;

        System.out.println(fivehundreds * 1000 + fives * 5);
    }
}
