const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
 
    const lines = input.split('\n')
    const N = lines[0] - 0

    let s = 0
    s = (N * N + N) / 2
    for (let i = 3; i <= N; i  += 3) {
        s -= i
    }
    for (let i = 5; i <= N; i  += 5) {
        if (i % 3 !== 0) {
            s -= i
        }
    }

    console.log(s)

})(input)
