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

