function Main(n) {
    let a = 0;
    for (let i=n;i>0;i--) {
        if(i % 3 === 0 || i % 5 === 0 || i % 15 === 0) {
            continue;
        } else {
            a = a + i;
        }
    }
    console.log(a);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));