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

		int haveyen = sc.nextInt();
		int money500 = haveyen / 500;
		int happy500 = money500 * 1000 ;
		int money5 = (haveyen - (money500 * 500)) / 5;
		int happy5 = money5 * 5;

		System.out.println(happy500 + happy5);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int haveyen = sc.nextInt();
		int money500 = haveyen / 500;
		int happy500 = money500 * 1000 ;
		int money5 = (haveyen - (money500 * 500)) / 5;
		int happy5 = money5 * 5;

		System.out.println(happy500 + happy5);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int haveyen = sc.nextInt();
		int money500 = haveyen / 500;
		int happy500 = money500 * 1000 ;
		int money5 = (haveyen - (money500 * 500)) / 5;
		int happy5 = money5 * 5;

		System.out.println(happy500 + happy5);
	} main {
		Scanner sc = new Scanner(System.in);

		int haveyen = sc.nextInt();
		int money500 = haveyen / 500;
		int happy500 = money500 * 1000 ;
		int money5 = (haveyen - (money500 * 500)) / 5;
		int happy5 = money5 * 5;

		System.out.println(happy500 + happy5);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int haveyen = sc.nextInt(); haveyen sc.nextInt() sc.nextInt sc int money500 = haveyen / 500; money500 haveyen / 500 haveyen 500 int happy500 = money500 * 1000 ; happy500 money500 * 1000 money500 1000 int money5 = (haveyen - (money500 * 500)) / 5; money5 (haveyen - (money500 * 500)) / 5 (haveyen - (money500 * 500)) haveyen (money500 * 500) money500 500 5 int happy5 = money5 * 5; happy5 money5 * 5 money5 5 System.out.println(happy500 + happy5) System.out.println System.out System System.out happy500 + happy5 happy500 happy5 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int haveyen = sc.nextInt();
		int money500 = haveyen / 500;
		int happy500 = money500 * 1000 ;
		int money5 = (haveyen - (money500 * 500)) / 5;
		int happy5 = money5 * 5;

		System.out.println(happy500 + happy5);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int haveyen = sc.nextInt();
		int money500 = haveyen / 500;
		int happy500 = money500 * 1000 ;
		int money5 = (haveyen - (money500 * 500)) / 5;
		int happy5 = money5 * 5;

		System.out.println(happy500 + happy5);
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int haveyen = sc.nextInt();
		int money500 = haveyen / 500;
		int happy500 = money500 * 1000 ;
		int money5 = (haveyen - (money500 * 500)) / 5;
		int happy5 = money5 * 5;

		System.out.println(happy500 + happy5);
	}
}