import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int total = sc.nextInt();

//	500円玉と5円玉の枚数を数える
		int ureshisa500 = total/500;
		int ureshisa5 = (total%500)/5;

		//	枚数分の 嬉しさ を計算して表示
		System.out.print(ureshisa500*1000 + ureshisa5*5);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int total = sc.nextInt();

//	500円玉と5円玉の枚数を数える
		int ureshisa500 = total/500;
		int ureshisa5 = (total%500)/5;

		//	枚数分の 嬉しさ を計算して表示
		System.out.print(ureshisa500*1000 + ureshisa5*5);
	}
} Main public static void main(String[] args) {

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int total = sc.nextInt();

//	500円玉と5円玉の枚数を数える
		int ureshisa500 = total/500;
		int ureshisa5 = (total%500)/5;

		//	枚数分の 嬉しさ を計算して表示
		System.out.print(ureshisa500*1000 + ureshisa5*5);
	} main {

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int total = sc.nextInt();

//	500円玉と5円玉の枚数を数える
		int ureshisa500 = total/500;
		int ureshisa5 = (total%500)/5;

		//	枚数分の 嬉しさ を計算して表示
		System.out.print(ureshisa500*1000 + ureshisa5*5);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int total = sc.nextInt(); total sc.nextInt() sc.nextInt sc int ureshisa500 = total/500; ureshisa500 total/500 total 500 int ureshisa5 = (total%500)/5; ureshisa5 (total%500)/5 (total%500) total 500 5 System.out.print(ureshisa500*1000 + ureshisa5*5) System.out.print System.out System System.out ureshisa500*1000 + ureshisa5*5 ureshisa500*1000 ureshisa500 1000 ureshisa5*5 ureshisa5 5 String[] args args public class Main {
	public static void main(String[] args) {

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int total = sc.nextInt();

//	500円玉と5円玉の枚数を数える
		int ureshisa500 = total/500;
		int ureshisa5 = (total%500)/5;

		//	枚数分の 嬉しさ を計算して表示
		System.out.print(ureshisa500*1000 + ureshisa5*5);
	}
} public class Main {
	public static void main(String[] args) {

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int total = sc.nextInt();

//	500円玉と5円玉の枚数を数える
		int ureshisa500 = total/500;
		int ureshisa5 = (total%500)/5;

		//	枚数分の 嬉しさ を計算して表示
		System.out.print(ureshisa500*1000 + ureshisa5*5);
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int total = sc.nextInt();

//	500円玉と5円玉の枚数を数える
		int ureshisa500 = total/500;
		int ureshisa5 = (total%500)/5;

		//	枚数分の 嬉しさ を計算して表示
		System.out.print(ureshisa500*1000 + ureshisa5*5);
	}
}
