#include<stdio.h>

int main(void){
    int N;
    scanf("%d",&N);

    unsigned long i,sum=0;

    for(i=0;i<N;i++){
        if(i%3!=0&&i%5!=0)  sum+=i;
    }

    printf("%lu\n",sum);

    return 0;
}