import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
	Scanner scan =new Scanner(System.in);
	int kouka =scan.nextInt();
	int  fivehundreds =500;
	int five =5;

	int a=kouka/fivehundreds;
	int nokori =kouka-a*fivehundreds;
	int b=nokori/five;
	int c=1000*a+5*b;

	System.out.println(c);
	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
	Scanner scan =new Scanner(System.in);
	int kouka =scan.nextInt();
	int  fivehundreds =500;
	int five =5;

	int a=kouka/fivehundreds;
	int nokori =kouka-a*fivehundreds;
	int b=nokori/five;
	int c=1000*a+5*b;

	System.out.println(c);
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
	Scanner scan =new Scanner(System.in);
	int kouka =scan.nextInt();
	int  fivehundreds =500;
	int five =5;

	int a=kouka/fivehundreds;
	int nokori =kouka-a*fivehundreds;
	int b=nokori/five;
	int c=1000*a+5*b;

	System.out.println(c);
	} main {
		// TODO 自動生成されたメソッド・スタブ
	Scanner scan =new Scanner(System.in);
	int kouka =scan.nextInt();
	int  fivehundreds =500;
	int five =5;

	int a=kouka/fivehundreds;
	int nokori =kouka-a*fivehundreds;
	int b=nokori/five;
	int c=1000*a+5*b;

	System.out.println(c);
	} Scanner scan =new Scanner(System.in); scan new Scanner(System.in) int kouka =scan.nextInt(); kouka scan.nextInt() scan.nextInt scan int  fivehundreds =500; fivehundreds 500 int five =5; five 5 int a=kouka/fivehundreds; a kouka/fivehundreds kouka fivehundreds int nokori =kouka-a*fivehundreds; nokori kouka-a*fivehundreds kouka a*fivehundreds a fivehundreds int b=nokori/five; b nokori/five nokori five int c=1000*a+5*b; c 1000*a+5*b 1000*a 1000 a 5*b 5 b System.out.println(c) System.out.println System.out System System.out c String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
	Scanner scan =new Scanner(System.in);
	int kouka =scan.nextInt();
	int  fivehundreds =500;
	int five =5;

	int a=kouka/fivehundreds;
	int nokori =kouka-a*fivehundreds;
	int b=nokori/five;
	int c=1000*a+5*b;

	System.out.println(c);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
	Scanner scan =new Scanner(System.in);
	int kouka =scan.nextInt();
	int  fivehundreds =500;
	int five =5;

	int a=kouka/fivehundreds;
	int nokori =kouka-a*fivehundreds;
	int b=nokori/five;
	int c=1000*a+5*b;

	System.out.println(c);
	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
	Scanner scan =new Scanner(System.in);
	int kouka =scan.nextInt();
	int  fivehundreds =500;
	int five =5;

	int a=kouka/fivehundreds;
	int nokori =kouka-a*fivehundreds;
	int b=nokori/five;
	int c=1000*a+5*b;

	System.out.println(c);
	}

}
