const main = input => {
  const n = parseInt(input)
  let r = 0;
  for (let i = 1; i <= n; i++) if (i % 3 != 0 && i % 5 != 0) r += i
  return r
}

console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')));