import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int happy = 0;
    int change = 0;
    while (change+500 <= x) {
      happy += 1000;
      change += 500;
    }
    while (change+5 <= x) {
      happy += 5;
      change += 5;
    }
    System.out.println(happy);
    sc.close();
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int happy = 0;
    int change = 0;
    while (change+500 <= x) {
      happy += 1000;
      change += 500;
    }
    while (change+5 <= x) {
      happy += 5;
      change += 5;
    }
    System.out.println(happy);
    sc.close();
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int happy = 0;
    int change = 0;
    while (change+500 <= x) {
      happy += 1000;
      change += 500;
    }
    while (change+5 <= x) {
      happy += 5;
      change += 5;
    }
    System.out.println(happy);
    sc.close();
  } main {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int happy = 0;
    int change = 0;
    while (change+500 <= x) {
      happy += 1000;
      change += 500;
    }
    while (change+5 <= x) {
      happy += 5;
      change += 5;
    }
    System.out.println(happy);
    sc.close();
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int happy = 0; happy 0 int change = 0; change 0 while (change+500 <= x) {
      happy += 1000;
      change += 500;
    } change+500 <= x change+500 change 500 x {
      happy += 1000;
      change += 500;
    } happy += 1000 happy 1000 change += 500 change 500 while (change+5 <= x) {
      happy += 5;
      change += 5;
    } change+5 <= x change+5 change 5 x {
      happy += 5;
      change += 5;
    } happy += 5 happy 5 change += 5 change 5 System.out.println(happy) System.out.println System.out System System.out happy sc.close() sc.close sc String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int happy = 0;
    int change = 0;
    while (change+500 <= x) {
      happy += 1000;
      change += 500;
    }
    while (change+5 <= x) {
      happy += 5;
      change += 5;
    }
    System.out.println(happy);
    sc.close();
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int happy = 0;
    int change = 0;
    while (change+500 <= x) {
      happy += 1000;
      change += 500;
    }
    while (change+5 <= x) {
      happy += 5;
      change += 5;
    }
    System.out.println(happy);
    sc.close();
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int happy = 0;
    int change = 0;
    while (change+500 <= x) {
      happy += 1000;
      change += 500;
    }
    while (change+5 <= x) {
      happy += 5;
      change += 5;
    }
    System.out.println(happy);
    sc.close();
  }
}