'use strict'
function main(input) {
    const tmp = input.split(' ');
    const L = parseInt(tmp[0], 10);

    const Lmod = L % 2019;
    console.log(Lmod * (Lmod + 1));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));