'use strict';
function main(input) {
  const a = Number(input.trim().split('\n')[0]);
  let sum = 0;

  for (let i = 1; i < (a + 1); i ++) {
    if (i % 3 === 0 || i % 5 === 0) {
      continue;
    }
    sum += i;
  }
  
  console.log(sum);
}

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