function main(input){
    tmp=0;
    while(tmp<=input){ 
        tmp+=500;
    }
    a=tmp*2;
    tmp2=0;
    while(tmp2<=input-tmp){
        tmp2+=5;
    }
    a+=tmp2;
    console.log("%d",a);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));