'use strict'
const Main=input=>{
    const num=parseInt(input);
    let sum=0;
    for(let i=1;i<num+1;i++){
        if(!(i%3==0||i%5==0)){
            sum+=i;
        }
    }
    
    console.log(sum);
}

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