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

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

    const f = n => n * (n + 1) / 2
    let s = 0
    s = f(N)
    s -= f(Math.floor(N / 3)) * 3
    s -= f(Math.floor(N / 5)) * 5
    s += f(Math.floor(N / 15)) * 15

    console.log(s)

})(input)
