"use strict";
function main(input) {
  const n = parseInt(input[0]);
  let sum = 0;

  for(let i=1;i<=n;i++){
    if((i%3===0) || (i%5===0)){
    }else{
      sum += i;
    }
  }
  console.log(sum);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));