import java.util.Scanner;

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

        int coins = input.nextInt();
        int fiveHumHappy = coins/500;
        int remainder = coins%500;
        int fiveHapyy = remainder/5;

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

        int coins = input.nextInt();
        int fiveHumHappy = coins/500;
        int remainder = coins%500;
        int fiveHapyy = remainder/5;

        System.out.println(((fiveHapyy*5)+(fiveHumHappy*1000)));
    }
} Main public static void main(String[] args) {
        final Scanner input =new Scanner(System.in);

        int coins = input.nextInt();
        int fiveHumHappy = coins/500;
        int remainder = coins%500;
        int fiveHapyy = remainder/5;

        System.out.println(((fiveHapyy*5)+(fiveHumHappy*1000)));
    } main {
        final Scanner input =new Scanner(System.in);

        int coins = input.nextInt();
        int fiveHumHappy = coins/500;
        int remainder = coins%500;
        int fiveHapyy = remainder/5;

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

        int coins = input.nextInt();
        int fiveHumHappy = coins/500;
        int remainder = coins%500;
        int fiveHapyy = remainder/5;

        System.out.println(((fiveHapyy*5)+(fiveHumHappy*1000)));
    }
} public class Main {
    public static void main(String[] args) {
        final Scanner input =new Scanner(System.in);

        int coins = input.nextInt();
        int fiveHumHappy = coins/500;
        int remainder = coins%500;
        int fiveHapyy = remainder/5;

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

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

        int coins = input.nextInt();
        int fiveHumHappy = coins/500;
        int remainder = coins%500;
        int fiveHapyy = remainder/5;

        System.out.println(((fiveHapyy*5)+(fiveHumHappy*1000)));
    }
}
