function main(input) {
  const N = Number(input)
  const arr = Array.from(new Array(N)).map((e, i) => i + 1)
  // console.log(arr)
  const sum = arr.reduce((h, e) => {
    if (e % 5 !== 0 && e % 3 !== 0) {
      return h + e
    } else {
      return h
    }
  }, 0)
  console.log(sum)

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