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

      Scanner sc = new Scanner(System.in);
      int money = sc.nextInt();
      int happy = (money/500)*1000 + ((money%500)/5)*5;

      System.out.println(happy);
    }
} import java.util.*; util.* java public class Main {
  	public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);
      int money = sc.nextInt();
      int happy = (money/500)*1000 + ((money%500)/5)*5;

      System.out.println(happy);
    }
} Main public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);
      int money = sc.nextInt();
      int happy = (money/500)*1000 + ((money%500)/5)*5;

      System.out.println(happy);
    } main {

      Scanner sc = new Scanner(System.in);
      int money = sc.nextInt();
      int happy = (money/500)*1000 + ((money%500)/5)*5;

      System.out.println(happy);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int money = sc.nextInt(); money sc.nextInt() sc.nextInt sc int happy = (money/500)*1000 + ((money%500)/5)*5; happy (money/500)*1000 + ((money%500)/5)*5 (money/500)*1000 (money/500) money 500 1000 ((money%500)/5)*5 ((money%500)/5) (money%500) money 500 5 5 System.out.println(happy) System.out.println System.out System System.out happy String[] args args public class Main {
  	public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);
      int money = sc.nextInt();
      int happy = (money/500)*1000 + ((money%500)/5)*5;

      System.out.println(happy);
    }
} public class Main {
  	public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);
      int money = sc.nextInt();
      int happy = (money/500)*1000 + ((money%500)/5)*5;

      System.out.println(happy);
    }
} Main
import java.util.*;
 
public class Main {
  	public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);
      int money = sc.nextInt();
      int happy = (money/500)*1000 + ((money%500)/5)*5;

      System.out.println(happy);
    }
}