function Main(input){
    var sum = 0;
    for(var i=1;i<=input;i++){
        if(i%5!=0&&i%3!=0) sum += i;
        
    }
    console.log(sum)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());