#include<stdio.h>
#include<stdlib.h>
#include <string.h>

int main(void){
  long int N;

long int count=0;

scanf("%ld", &N);

while(N!=0){
    if(N%3 != 0 && N%5!=0){
count += N;
    }
    N -= 1;
}
  
  printf("%ld\n", count);
  return 0;
}
