import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int money = scanner.nextInt();
        int value = (money / 500) * 1000;
        value += ((money % 500) / 5) * 5;
        System.out.println(value);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int money = scanner.nextInt();
        int value = (money / 500) * 1000;
        value += ((money % 500) / 5) * 5;
        System.out.println(value);
    }
} Main public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int money = scanner.nextInt();
        int value = (money / 500) * 1000;
        value += ((money % 500) / 5) * 5;
        System.out.println(value);
    } main {
        final Scanner scanner = new Scanner(System.in);
        final int money = scanner.nextInt();
        int value = (money / 500) * 1000;
        value += ((money % 500) / 5) * 5;
        System.out.println(value);
    } final Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) final int money = scanner.nextInt(); money scanner.nextInt() scanner.nextInt scanner int value = (money / 500) * 1000; value (money / 500) * 1000 (money / 500) money 500 1000 value += ((money % 500) / 5) * 5 value ((money % 500) / 5) * 5 ((money % 500) / 5) (money % 500) money 500 5 5 System.out.println(value) System.out.println System.out System System.out value String[] args args public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int money = scanner.nextInt();
        int value = (money / 500) * 1000;
        value += ((money % 500) / 5) * 5;
        System.out.println(value);
    }
} public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int money = scanner.nextInt();
        int value = (money / 500) * 1000;
        value += ((money % 500) / 5) * 5;
        System.out.println(value);
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int money = scanner.nextInt();
        int value = (money / 500) * 1000;
        value += ((money % 500) / 5) * 5;
        System.out.println(value);
    }
}
