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