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