import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int input = Integer.parseInt(scan.next());
        //int second = Integer.parseInt(scan.next());
        //long in = Long.parseLong(scan.next());
        //String s = scan.next();
        //String second = scan.next();
        //for (int i = 1; i <=input; i++) {
        //}
        int yen500cnt = input/500;
        int div = input%500;
        int yen5cnt = div/5;
        System.out.println((yen500cnt*1000) + (yen5cnt*5));
    }

    public static void res(boolean flg) {
        if(flg) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int input = Integer.parseInt(scan.next());
        //int second = Integer.parseInt(scan.next());
        //long in = Long.parseLong(scan.next());
        //String s = scan.next();
        //String second = scan.next();
        //for (int i = 1; i <=input; i++) {
        //}
        int yen500cnt = input/500;
        int div = input%500;
        int yen5cnt = div/5;
        System.out.println((yen500cnt*1000) + (yen5cnt*5));
    }

    public static void res(boolean flg) {
        if(flg) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int input = Integer.parseInt(scan.next());
        //int second = Integer.parseInt(scan.next());
        //long in = Long.parseLong(scan.next());
        //String s = scan.next();
        //String second = scan.next();
        //for (int i = 1; i <=input; i++) {
        //}
        int yen500cnt = input/500;
        int div = input%500;
        int yen5cnt = div/5;
        System.out.println((yen500cnt*1000) + (yen5cnt*5));
    } main {
        Scanner scan = new Scanner(System.in);
        int input = Integer.parseInt(scan.next());
        //int second = Integer.parseInt(scan.next());
        //long in = Long.parseLong(scan.next());
        //String s = scan.next();
        //String second = scan.next();
        //for (int i = 1; i <=input; i++) {
        //}
        int yen500cnt = input/500;
        int div = input%500;
        int yen5cnt = div/5;
        System.out.println((yen500cnt*1000) + (yen5cnt*5));
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int input = Integer.parseInt(scan.next()); input Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan int yen500cnt = input/500; yen500cnt input/500 input 500 int div = input%500; div input%500 input 500 int yen5cnt = div/5; yen5cnt div/5 div 5 System.out.println((yen500cnt*1000) + (yen5cnt*5)) System.out.println System.out System System.out (yen500cnt*1000) + (yen5cnt*5) (yen500cnt*1000) yen500cnt 1000 (yen5cnt*5) yen5cnt 5 String[] args args public static void res(boolean flg) {
        if(flg) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    } res {
        if(flg) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    } if(flg) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        } flg {
            System.out.println("Yes");
        } System.out.println("Yes") System.out.println System.out System System.out "Yes" {
            System.out.println("No");
        } System.out.println("No") System.out.println System.out System System.out "No" boolean flg flg public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int input = Integer.parseInt(scan.next());
        //int second = Integer.parseInt(scan.next());
        //long in = Long.parseLong(scan.next());
        //String s = scan.next();
        //String second = scan.next();
        //for (int i = 1; i <=input; i++) {
        //}
        int yen500cnt = input/500;
        int div = input%500;
        int yen5cnt = div/5;
        System.out.println((yen500cnt*1000) + (yen5cnt*5));
    }

    public static void res(boolean flg) {
        if(flg) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int input = Integer.parseInt(scan.next());
        //int second = Integer.parseInt(scan.next());
        //long in = Long.parseLong(scan.next());
        //String s = scan.next();
        //String second = scan.next();
        //for (int i = 1; i <=input; i++) {
        //}
        int yen500cnt = input/500;
        int div = input%500;
        int yen5cnt = div/5;
        System.out.println((yen500cnt*1000) + (yen5cnt*5));
    }

    public static void res(boolean flg) {
        if(flg) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int input = Integer.parseInt(scan.next());
        //int second = Integer.parseInt(scan.next());
        //long in = Long.parseLong(scan.next());
        //String s = scan.next();
        //String second = scan.next();
        //for (int i = 1; i <=input; i++) {
        //}
        int yen500cnt = input/500;
        int div = input%500;
        int yen5cnt = div/5;
        System.out.println((yen500cnt*1000) + (yen5cnt*5));
    }

    public static void res(boolean flg) {
        if(flg) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}
