import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int yen = scanner.nextInt();
        int divValue, modValue, totalHp;

        divValue = yen / 500;
        totalHp = divValue * 1000;
        modValue = yen % 500;

        if (modValue != 0) {
            divValue = modValue / 5;
            totalHp = totalHp + divValue * 5;
        }
        System.out.println(totalHp);


    }
} import java.util.Scanner; Scanner java.util public class Main {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int yen = scanner.nextInt();
        int divValue, modValue, totalHp;

        divValue = yen / 500;
        totalHp = divValue * 1000;
        modValue = yen % 500;

        if (modValue != 0) {
            divValue = modValue / 5;
            totalHp = totalHp + divValue * 5;
        }
        System.out.println(totalHp);


    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int yen = scanner.nextInt();
        int divValue, modValue, totalHp;

        divValue = yen / 500;
        totalHp = divValue * 1000;
        modValue = yen % 500;

        if (modValue != 0) {
            divValue = modValue / 5;
            totalHp = totalHp + divValue * 5;
        }
        System.out.println(totalHp);


    } main {
        Scanner scanner = new Scanner(System.in);
        int yen = scanner.nextInt();
        int divValue, modValue, totalHp;

        divValue = yen / 500;
        totalHp = divValue * 1000;
        modValue = yen % 500;

        if (modValue != 0) {
            divValue = modValue / 5;
            totalHp = totalHp + divValue * 5;
        }
        System.out.println(totalHp);


    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int yen = scanner.nextInt(); yen scanner.nextInt() scanner.nextInt scanner int divValue divValue modValue modValue totalHp; totalHp divValue = yen / 500 divValue yen / 500 yen 500 totalHp = divValue * 1000 totalHp divValue * 1000 divValue 1000 modValue = yen % 500 modValue yen % 500 yen 500 if (modValue != 0) {
            divValue = modValue / 5;
            totalHp = totalHp + divValue * 5;
        } modValue != 0 modValue 0 {
            divValue = modValue / 5;
            totalHp = totalHp + divValue * 5;
        } divValue = modValue / 5 divValue modValue / 5 modValue 5 totalHp = totalHp + divValue * 5 totalHp totalHp + divValue * 5 totalHp divValue * 5 divValue 5 System.out.println(totalHp) System.out.println System.out System System.out totalHp String[] args args public class Main {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int yen = scanner.nextInt();
        int divValue, modValue, totalHp;

        divValue = yen / 500;
        totalHp = divValue * 1000;
        modValue = yen % 500;

        if (modValue != 0) {
            divValue = modValue / 5;
            totalHp = totalHp + divValue * 5;
        }
        System.out.println(totalHp);


    }
} public class Main {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int yen = scanner.nextInt();
        int divValue, modValue, totalHp;

        divValue = yen / 500;
        totalHp = divValue * 1000;
        modValue = yen % 500;

        if (modValue != 0) {
            divValue = modValue / 5;
            totalHp = totalHp + divValue * 5;
        }
        System.out.println(totalHp);


    }
} Main
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int yen = scanner.nextInt();
        int divValue, modValue, totalHp;

        divValue = yen / 500;
        totalHp = divValue * 1000;
        modValue = yen % 500;

        if (modValue != 0) {
            divValue = modValue / 5;
            totalHp = totalHp + divValue * 5;
        }
        System.out.println(totalHp);


    }
}