import java.util.Scanner;

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

        int X = sc.nextInt();

        int c500 = X / 500; // 500円枚数
        int c = X % 500;
        int c5 = c / 5; // 5円枚数

        System.out.print((c500*1000) + (c5*5));
    }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();

        int c500 = X / 500; // 500円枚数
        int c = X % 500;
        int c5 = c / 5; // 5円枚数

        System.out.print((c500*1000) + (c5*5));
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();

        int c500 = X / 500; // 500円枚数
        int c = X % 500;
        int c5 = c / 5; // 5円枚数

        System.out.print((c500*1000) + (c5*5));
    } main {
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();

        int c500 = X / 500; // 500円枚数
        int c = X % 500;
        int c5 = c / 5; // 5円枚数

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

        int X = sc.nextInt();

        int c500 = X / 500; // 500円枚数
        int c = X % 500;
        int c5 = c / 5; // 5円枚数

        System.out.print((c500*1000) + (c5*5));
    }
} public class Main {
  public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();

        int c500 = X / 500; // 500円枚数
        int c = X % 500;
        int c5 = c / 5; // 5円枚数

        System.out.print((c500*1000) + (c5*5));
    }
} Main
import java.util.Scanner;

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

        int X = sc.nextInt();

        int c500 = X / 500; // 500円枚数
        int c = X % 500;
        int c5 = c / 5; // 5円枚数

        System.out.print((c500*1000) + (c5*5));
    }
}