import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int zankin = sc.nextInt();
        int i = 0;
        int j = 0;
      
      while (zankin - 500 * (i + 1) >= 0 ) {
        i = i + 1 ;
      }
      zankin = zankin - 500 * i ;
      
      while (zankin - 5 * (j + 1) >= 0 ) {
        j = j + 1 ;
      }
      
      System.out.println(i * 1000 + j * 5);

    }
}
 import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int zankin = sc.nextInt();
        int i = 0;
        int j = 0;
      
      while (zankin - 500 * (i + 1) >= 0 ) {
        i = i + 1 ;
      }
      zankin = zankin - 500 * i ;
      
      while (zankin - 5 * (j + 1) >= 0 ) {
        j = j + 1 ;
      }
      
      System.out.println(i * 1000 + j * 5);

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int zankin = sc.nextInt();
        int i = 0;
        int j = 0;
      
      while (zankin - 500 * (i + 1) >= 0 ) {
        i = i + 1 ;
      }
      zankin = zankin - 500 * i ;
      
      while (zankin - 5 * (j + 1) >= 0 ) {
        j = j + 1 ;
      }
      
      System.out.println(i * 1000 + j * 5);

    } main {
        Scanner sc = new Scanner(System.in);
        int zankin = sc.nextInt();
        int i = 0;
        int j = 0;
      
      while (zankin - 500 * (i + 1) >= 0 ) {
        i = i + 1 ;
      }
      zankin = zankin - 500 * i ;
      
      while (zankin - 5 * (j + 1) >= 0 ) {
        j = j + 1 ;
      }
      
      System.out.println(i * 1000 + j * 5);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int zankin = sc.nextInt(); zankin sc.nextInt() sc.nextInt sc int i = 0; i 0 int j = 0; j 0 while (zankin - 500 * (i + 1) >= 0 ) {
        i = i + 1 ;
      } zankin - 500 * (i + 1) >= 0 zankin - 500 * (i + 1) zankin 500 * (i + 1) 500 (i + 1) i 1 0 {
        i = i + 1 ;
      } i = i + 1 i i + 1 i 1 zankin = zankin - 500 * i zankin zankin - 500 * i zankin 500 * i 500 i while (zankin - 5 * (j + 1) >= 0 ) {
        j = j + 1 ;
      } zankin - 5 * (j + 1) >= 0 zankin - 5 * (j + 1) zankin 5 * (j + 1) 5 (j + 1) j 1 0 {
        j = j + 1 ;
      } j = j + 1 j j + 1 j 1 System.out.println(i * 1000 + j * 5) System.out.println System.out System System.out i * 1000 + j * 5 i * 1000 i 1000 j * 5 j 5 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int zankin = sc.nextInt();
        int i = 0;
        int j = 0;
      
      while (zankin - 500 * (i + 1) >= 0 ) {
        i = i + 1 ;
      }
      zankin = zankin - 500 * i ;
      
      while (zankin - 5 * (j + 1) >= 0 ) {
        j = j + 1 ;
      }
      
      System.out.println(i * 1000 + j * 5);

    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int zankin = sc.nextInt();
        int i = 0;
        int j = 0;
      
      while (zankin - 500 * (i + 1) >= 0 ) {
        i = i + 1 ;
      }
      zankin = zankin - 500 * i ;
      
      while (zankin - 5 * (j + 1) >= 0 ) {
        j = j + 1 ;
      }
      
      System.out.println(i * 1000 + j * 5);

    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int zankin = sc.nextInt();
        int i = 0;
        int j = 0;
      
      while (zankin - 500 * (i + 1) >= 0 ) {
        i = i + 1 ;
      }
      zankin = zankin - 500 * i ;
      
      while (zankin - 5 * (j + 1) >= 0 ) {
        j = j + 1 ;
      }
      
      System.out.println(i * 1000 + j * 5);

    }
}

