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