function Main(input) {
  let sum = 0;
  for (let i = 1; i <= input; i++) {
    if (i % 3 !== 0 && i % 5 !== 0) {
      sum += i;
    }
  }

  console.log(sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));