import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int total = sc.nextInt();
        int happy500 = 0;
        int happy5 = 0;
        happy500 = total / 500 * 1000;
        happy5 = (total % 500) / 5 * 5;
        System.out.println(happy500 + happy5);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int total = sc.nextInt();
        int happy500 = 0;
        int happy5 = 0;
        happy500 = total / 500 * 1000;
        happy5 = (total % 500) / 5 * 5;
        System.out.println(happy500 + happy5);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int total = sc.nextInt();
        int happy500 = 0;
        int happy5 = 0;
        happy500 = total / 500 * 1000;
        happy5 = (total % 500) / 5 * 5;
        System.out.println(happy500 + happy5);
    } main {
        Scanner sc = new Scanner(System.in);
        int total = sc.nextInt();
        int happy500 = 0;
        int happy5 = 0;
        happy500 = total / 500 * 1000;
        happy5 = (total % 500) / 5 * 5;
        System.out.println(happy500 + happy5);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int total = sc.nextInt(); total sc.nextInt() sc.nextInt sc int happy500 = 0; happy500 0 int happy5 = 0; happy5 0 happy500 = total / 500 * 1000 happy500 total / 500 * 1000 total / 500 total 500 1000 happy5 = (total % 500) / 5 * 5 happy5 (total % 500) / 5 * 5 (total % 500) / 5 (total % 500) total 500 5 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 total = sc.nextInt();
        int happy500 = 0;
        int happy5 = 0;
        happy500 = total / 500 * 1000;
        happy5 = (total % 500) / 5 * 5;
        System.out.println(happy500 + happy5);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int total = sc.nextInt();
        int happy500 = 0;
        int happy5 = 0;
        happy500 = total / 500 * 1000;
        happy5 = (total % 500) / 5 * 5;
        System.out.println(happy500 + happy5);
    }
} Main
import java.util.*;

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