const main = input => {
    const N = parseInt(input.trim());
    let count = 0;
    for (let i = 1; i <= N; i++) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
            count += i;
        }
    }

    console.log(count);
};

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"));
