"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const n = Number(spi[0]);
    let ans = 0n;
    for (let i = 1; i <= n; i++) {
        if (i % 3 !== 0 && i % 5 !== 0) ans += BigInt(i);
    }

    console.log(ans.toString());
};

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