
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author wnqmw
 */
public class Main {
    public static void main(String args[]){
        Scanner kb = new Scanner(System.in);
        
        int yen = kb.nextInt();
        int total = 0;
        total += (yen/500)*1000;
        yen -= (yen/500)*500;
        total += (yen/5)*5;
        
        System.out.println(total);
        
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]){
        Scanner kb = new Scanner(System.in);
        
        int yen = kb.nextInt();
        int total = 0;
        total += (yen/500)*1000;
        yen -= (yen/500)*500;
        total += (yen/5)*5;
        
        System.out.println(total);
        
    }
} Main public static void main(String args[]){
        Scanner kb = new Scanner(System.in);
        
        int yen = kb.nextInt();
        int total = 0;
        total += (yen/500)*1000;
        yen -= (yen/500)*500;
        total += (yen/5)*5;
        
        System.out.println(total);
        
    } main {
        Scanner kb = new Scanner(System.in);
        
        int yen = kb.nextInt();
        int total = 0;
        total += (yen/500)*1000;
        yen -= (yen/500)*500;
        total += (yen/5)*5;
        
        System.out.println(total);
        
    } Scanner kb = new Scanner(System.in); kb new Scanner(System.in) int yen = kb.nextInt(); yen kb.nextInt() kb.nextInt kb int total = 0; total 0 total += (yen/500)*1000 total (yen/500)*1000 (yen/500) yen 500 1000 yen -= (yen/500)*500 yen (yen/500)*500 (yen/500) yen 500 500 total += (yen/5)*5 total (yen/5)*5 (yen/5) yen 5 5 System.out.println(total) System.out.println System.out System System.out total String args[] args public class Main {
    public static void main(String args[]){
        Scanner kb = new Scanner(System.in);
        
        int yen = kb.nextInt();
        int total = 0;
        total += (yen/500)*1000;
        yen -= (yen/500)*500;
        total += (yen/5)*5;
        
        System.out.println(total);
        
    }
} public class Main {
    public static void main(String args[]){
        Scanner kb = new Scanner(System.in);
        
        int yen = kb.nextInt();
        int total = 0;
        total += (yen/500)*1000;
        yen -= (yen/500)*500;
        total += (yen/5)*5;
        
        System.out.println(total);
        
    }
} Main

import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author wnqmw
 */
public class Main {
    public static void main(String args[]){
        Scanner kb = new Scanner(System.in);
        
        int yen = kb.nextInt();
        int total = 0;
        total += (yen/500)*1000;
        yen -= (yen/500)*500;
        total += (yen/5)*5;
        
        System.out.println(total);
        
    }
}
