"use strict"
function main(arg) {
      
    let aaa = arg.trim().split("\n")[0];

    let gohyaku = parseInt(aaa / 500);

    let goen = parseInt((aaa -  (gohyaku * 500)) / 5);




    console.log((gohyaku * 1000) + (goen * 5));

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));