import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		        Scanner sc = new Scanner(System.in);
		        int money = sc.nextInt();

		        int point = 0;
		        //moneyが5以上ならくり返す
		        while(money >= 5) {
		        	//moneyが500以上か
		        	if(money >=500){
		        		point += 1000;
		        		money -= 500;
		        	}
		        	else if(money >= 5) {
		        		point += 5 ;
		        		money -= 5;
		        	}


		        }
		        System.out.println(point);
	}


} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		        Scanner sc = new Scanner(System.in);
		        int money = sc.nextInt();

		        int point = 0;
		        //moneyが5以上ならくり返す
		        while(money >= 5) {
		        	//moneyが500以上か
		        	if(money >=500){
		        		point += 1000;
		        		money -= 500;
		        	}
		        	else if(money >= 5) {
		        		point += 5 ;
		        		money -= 5;
		        	}


		        }
		        System.out.println(point);
	}


} Main public static void main(String[] args) {
		        Scanner sc = new Scanner(System.in);
		        int money = sc.nextInt();

		        int point = 0;
		        //moneyが5以上ならくり返す
		        while(money >= 5) {
		        	//moneyが500以上か
		        	if(money >=500){
		        		point += 1000;
		        		money -= 500;
		        	}
		        	else if(money >= 5) {
		        		point += 5 ;
		        		money -= 5;
		        	}


		        }
		        System.out.println(point);
	} main {
		        Scanner sc = new Scanner(System.in);
		        int money = sc.nextInt();

		        int point = 0;
		        //moneyが5以上ならくり返す
		        while(money >= 5) {
		        	//moneyが500以上か
		        	if(money >=500){
		        		point += 1000;
		        		money -= 500;
		        	}
		        	else if(money >= 5) {
		        		point += 5 ;
		        		money -= 5;
		        	}


		        }
		        System.out.println(point);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int money = sc.nextInt(); money sc.nextInt() sc.nextInt sc int point = 0; point 0 while(money >= 5) {
		        	//moneyが500以上か
		        	if(money >=500){
		        		point += 1000;
		        		money -= 500;
		        	}
		        	else if(money >= 5) {
		        		point += 5 ;
		        		money -= 5;
		        	}


		        } money >= 5 money 5 {
		        	//moneyが500以上か
		        	if(money >=500){
		        		point += 1000;
		        		money -= 500;
		        	}
		        	else if(money >= 5) {
		        		point += 5 ;
		        		money -= 5;
		        	}


		        } if(money >=500){
		        		point += 1000;
		        		money -= 500;
		        	}
		        	else if(money >= 5) {
		        		point += 5 ;
		        		money -= 5;
		        	} money >=500 money 500 {
		        		point += 1000;
		        		money -= 500;
		        	} point += 1000 point 1000 money -= 500 money 500 if(money >= 5) {
		        		point += 5 ;
		        		money -= 5;
		        	} money >= 5 money 5 {
		        		point += 5 ;
		        		money -= 5;
		        	} point += 5 point 5 money -= 5 money 5 System.out.println(point) System.out.println System.out System System.out point String[] args args public class Main {
	public static void main(String[] args) {
		        Scanner sc = new Scanner(System.in);
		        int money = sc.nextInt();

		        int point = 0;
		        //moneyが5以上ならくり返す
		        while(money >= 5) {
		        	//moneyが500以上か
		        	if(money >=500){
		        		point += 1000;
		        		money -= 500;
		        	}
		        	else if(money >= 5) {
		        		point += 5 ;
		        		money -= 5;
		        	}


		        }
		        System.out.println(point);
	}


} public class Main {
	public static void main(String[] args) {
		        Scanner sc = new Scanner(System.in);
		        int money = sc.nextInt();

		        int point = 0;
		        //moneyが5以上ならくり返す
		        while(money >= 5) {
		        	//moneyが500以上か
		        	if(money >=500){
		        		point += 1000;
		        		money -= 500;
		        	}
		        	else if(money >= 5) {
		        		point += 5 ;
		        		money -= 5;
		        	}


		        }
		        System.out.println(point);
	}


} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		        Scanner sc = new Scanner(System.in);
		        int money = sc.nextInt();

		        int point = 0;
		        //moneyが5以上ならくり返す
		        while(money >= 5) {
		        	//moneyが500以上か
		        	if(money >=500){
		        		point += 1000;
		        		money -= 500;
		        	}
		        	else if(money >= 5) {
		        		point += 5 ;
		        		money -= 5;
		        	}


		        }
		        System.out.println(point);
	}


}
