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