process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var n = lines[0];
 var sum = 0;
 for(i=1; i<=n; i++){
   if(i % 3 == 0 && i % 5 == 0){
     continue;
   }else if(i % 3 == 0){
     continue;
   }else if(i % 5 == 0){
     continue;
   }else{
     sum += i;
   }

 }

 console.log(sum);
});
