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

int main(void){
    long int n,i,sum = 0;
    scanf("%ld",&n);
  for (i=1;i<=n;++i){
       if(i%3 !=0 && i % 5 != 0){
           sum = sum + i;
       }
    }
printf("%ld\n",sum);
    
    return 0;
}