import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);    
    int num = scan.nextInt();
    scan.close();
        
    int hapiness = 0;
    
    hapiness += (num / 500) * 1000;
    
    hapiness += ((num % 500) / 5) * 5;
    
    System.out.println(hapiness);
  }
} import java.util.Scanner; Scanner java.util public class Main {

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

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

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);    
    int num = scan.nextInt();
    scan.close();
        
    int hapiness = 0;
    
    hapiness += (num / 500) * 1000;
    
    hapiness += ((num % 500) / 5) * 5;
    
    System.out.println(hapiness);
  }
} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);    
    int num = scan.nextInt();
    scan.close();
        
    int hapiness = 0;
    
    hapiness += (num / 500) * 1000;
    
    hapiness += ((num % 500) / 5) * 5;
    
    System.out.println(hapiness);
  }
}
