import java.util.*;

public class Main{
public static void main(String args[]){
	
	Scanner sc = new Scanner(System.in);
	int C = sc.nextInt();
	
	int a = C%500;
	int b = (a-(a%5));
	int c = (C-a)*2;
	
	System.out.println(b+c);
}
} import java.util.*; util.* java public class Main{
public static void main(String args[]){
	
	Scanner sc = new Scanner(System.in);
	int C = sc.nextInt();
	
	int a = C%500;
	int b = (a-(a%5));
	int c = (C-a)*2;
	
	System.out.println(b+c);
}
} Main public static void main(String args[]){
	
	Scanner sc = new Scanner(System.in);
	int C = sc.nextInt();
	
	int a = C%500;
	int b = (a-(a%5));
	int c = (C-a)*2;
	
	System.out.println(b+c);
} main {
	
	Scanner sc = new Scanner(System.in);
	int C = sc.nextInt();
	
	int a = C%500;
	int b = (a-(a%5));
	int c = (C-a)*2;
	
	System.out.println(b+c);
} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int C = sc.nextInt(); C sc.nextInt() sc.nextInt sc int a = C%500; a C%500 C 500 int b = (a-(a%5)); b (a-(a%5)) a (a%5) a 5 int c = (C-a)*2; c (C-a)*2 (C-a) C a 2 System.out.println(b+c) System.out.println System.out System System.out b+c b c String args[] args public class Main{
public static void main(String args[]){
	
	Scanner sc = new Scanner(System.in);
	int C = sc.nextInt();
	
	int a = C%500;
	int b = (a-(a%5));
	int c = (C-a)*2;
	
	System.out.println(b+c);
}
} public class Main{
public static void main(String args[]){
	
	Scanner sc = new Scanner(System.in);
	int C = sc.nextInt();
	
	int a = C%500;
	int b = (a-(a%5));
	int c = (C-a)*2;
	
	System.out.println(b+c);
}
} Main
import java.util.*;

public class Main{
public static void main(String args[]){
	
	Scanner sc = new Scanner(System.in);
	int C = sc.nextInt();
	
	int a = C%500;
	int b = (a-(a%5));
	int c = (C-a)*2;
	
	System.out.println(b+c);
}
}