import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        int coin500 = n / 500;
        int hapiness500 = coin500 * 1000;
        int coin5 = (n % 500) / 5;
        int hapiness5 = coin5 * 5;
        System.out.println(hapiness500 + hapiness5);
    }
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        int coin500 = n / 500;
        int hapiness500 = coin500 * 1000;
        int coin5 = (n % 500) / 5;
        int hapiness5 = coin5 * 5;
        System.out.println(hapiness500 + hapiness5);
    }
} Main public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        int coin500 = n / 500;
        int hapiness500 = coin500 * 1000;
        int coin5 = (n % 500) / 5;
        int hapiness5 = coin5 * 5;
        System.out.println(hapiness500 + hapiness5);
    } main {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        int coin500 = n / 500;
        int hapiness500 = coin500 * 1000;
        int coin5 = (n % 500) / 5;
        int hapiness5 = coin5 * 5;
        System.out.println(hapiness500 + hapiness5);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int coin500 = n / 500; coin500 n / 500 n 500 int hapiness500 = coin500 * 1000; hapiness500 coin500 * 1000 coin500 1000 int coin5 = (n % 500) / 5; coin5 (n % 500) / 5 (n % 500) n 500 5 int hapiness5 = coin5 * 5; hapiness5 coin5 * 5 coin5 5 System.out.println(hapiness500 + hapiness5) System.out.println System.out System System.out hapiness500 + hapiness5 hapiness500 hapiness5 String[] args args public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        int coin500 = n / 500;
        int hapiness500 = coin500 * 1000;
        int coin5 = (n % 500) / 5;
        int hapiness5 = coin5 * 5;
        System.out.println(hapiness500 + hapiness5);
    }
} public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        int coin500 = n / 500;
        int hapiness500 = coin500 * 1000;
        int coin5 = (n % 500) / 5;
        int hapiness5 = coin5 * 5;
        System.out.println(hapiness500 + hapiness5);
    }
} Main
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        int coin500 = n / 500;
        int hapiness500 = coin500 * 1000;
        int coin5 = (n % 500) / 5;
        int hapiness5 = coin5 * 5;
        System.out.println(hapiness500 + hapiness5);
    }
}