import java.util.Scanner;
class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    long money , goen ,gohyaku;
    money = sc.nextInt();
    goen = (money % 500) / 5 * 5;
    gohyaku = (money / 500) *1000;
    System.out.println(goen + gohyaku);
  }
} import java.util.Scanner; Scanner java.util class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    long money , goen ,gohyaku;
    money = sc.nextInt();
    goen = (money % 500) / 5 * 5;
    gohyaku = (money / 500) *1000;
    System.out.println(goen + gohyaku);
  }
} Main public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    long money , goen ,gohyaku;
    money = sc.nextInt();
    goen = (money % 500) / 5 * 5;
    gohyaku = (money / 500) *1000;
    System.out.println(goen + gohyaku);
  } main {
    Scanner sc = new Scanner(System.in);
    long money , goen ,gohyaku;
    money = sc.nextInt();
    goen = (money % 500) / 5 * 5;
    gohyaku = (money / 500) *1000;
    System.out.println(goen + gohyaku);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long money money goen goen gohyaku; gohyaku money = sc.nextInt() money sc.nextInt() sc.nextInt sc goen = (money % 500) / 5 * 5 goen (money % 500) / 5 * 5 (money % 500) / 5 (money % 500) money 500 5 5 gohyaku = (money / 500) *1000 gohyaku (money / 500) *1000 (money / 500) money 500 1000 System.out.println(goen + gohyaku) System.out.println System.out System System.out goen + gohyaku goen gohyaku String args[] args
import java.util.Scanner;
class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    long money , goen ,gohyaku;
    money = sc.nextInt();
    goen = (money % 500) / 5 * 5;
    gohyaku = (money / 500) *1000;
    System.out.println(goen + gohyaku);
  }
}
