import java.util.Scanner;
public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
        long N = scan.nextLong();
long N500=N-N%500;
long N5=N-N500-N%5;

long p=N500*2+N5;
System.out.println(p);


    }

}
 import java.util.Scanner; Scanner java.util public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
        long N = scan.nextLong();
long N500=N-N%500;
long N5=N-N500-N%5;

long p=N500*2+N5;
System.out.println(p);


    }

} Main public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
        long N = scan.nextLong();
long N500=N-N%500;
long N5=N-N500-N%5;

long p=N500*2+N5;
System.out.println(p);


    } main {


        Scanner scan = new Scanner(System.in);
        long N = scan.nextLong();
long N500=N-N%500;
long N5=N-N500-N%5;

long p=N500*2+N5;
System.out.println(p);


    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long N = scan.nextLong(); N scan.nextLong() scan.nextLong scan long N500=N-N%500; N500 N-N%500 N N%500 N 500 long N5=N-N500-N%5; N5 N-N500-N%5 N-N500-N%5 N N500 N%5 N 5 long p=N500*2+N5; p N500*2+N5 N500*2 N500 2 N5 System.out.println(p) System.out.println System.out System System.out p String[] args args public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
        long N = scan.nextLong();
long N500=N-N%500;
long N5=N-N500-N%5;

long p=N500*2+N5;
System.out.println(p);


    }

} public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
        long N = scan.nextLong();
long N500=N-N%500;
long N5=N-N500-N%5;

long p=N500*2+N5;
System.out.println(p);


    }

} Main
import java.util.Scanner;
public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
        long N = scan.nextLong();
long N500=N-N%500;
long N5=N-N500-N%5;

long p=N500*2+N5;
System.out.println(p);


    }

}

