
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        int x = 500;
        int y = 5;
        long happy = (a/x)*1000+(a%x/y)*y;
        System.out.println(happy);
    }
} import java.util.Scanner; Scanner java.util class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        int x = 500;
        int y = 5;
        long happy = (a/x)*1000+(a%x/y)*y;
        System.out.println(happy);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        int x = 500;
        int y = 5;
        long happy = (a/x)*1000+(a%x/y)*y;
        System.out.println(happy);
    } main {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        int x = 500;
        int y = 5;
        long happy = (a/x)*1000+(a%x/y)*y;
        System.out.println(happy);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long a = sc.nextLong(); a sc.nextLong() sc.nextLong sc int x = 500; x 500 int y = 5; y 5 long happy = (a/x)*1000+(a%x/y)*y; happy (a/x)*1000+(a%x/y)*y (a/x)*1000 (a/x) a x 1000 (a%x/y)*y (a%x/y) a%x a x y y System.out.println(happy) System.out.println System.out System System.out happy String[] args args

import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        int x = 500;
        int y = 5;
        long happy = (a/x)*1000+(a%x/y)*y;
        System.out.println(happy);
    }
}