import java.util.Scanner;

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

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