import java.util.Scanner;
 public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
      
        int a =X%500;
        int b =X/500;
        int c =a/5;
      
      System.out.println((500*b)*2+5*c);
    }
 }
      
  import java.util.Scanner; Scanner java.util public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
      
        int a =X%500;
        int b =X/500;
        int c =a/5;
      
      System.out.println((500*b)*2+5*c);
    }
 } Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
      
        int a =X%500;
        int b =X/500;
        int c =a/5;
      
      System.out.println((500*b)*2+5*c);
    } main {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
      
        int a =X%500;
        int b =X/500;
        int c =a/5;
      
      System.out.println((500*b)*2+5*c);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int X = scanner.nextInt(); X scanner.nextInt() scanner.nextInt scanner int a =X%500; a X%500 X 500 int b =X/500; b X/500 X 500 int c =a/5; c a/5 a 5 System.out.println((500*b)*2+5*c) System.out.println System.out System System.out (500*b)*2+5*c (500*b)*2 (500*b) 500 b 2 5*c 5 c String[] args args public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
      
        int a =X%500;
        int b =X/500;
        int c =a/5;
      
      System.out.println((500*b)*2+5*c);
    }
 } public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
      
        int a =X%500;
        int b =X/500;
        int c =a/5;
      
      System.out.println((500*b)*2+5*c);
    }
 } Main
import java.util.Scanner;
 public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
      
        int a =X%500;
        int b =X/500;
        int c =a/5;
      
      System.out.println((500*b)*2+5*c);
    }
 }
      
 