#include<stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    int i;
    int j;
    int a[n];
    j=0;
    unsigned long sum=0;
    for(i=1;i<=n;++i){
        if(i%3!=0 && i%5!=0){
            sum+=i;
        }
    }
    printf("%lu\n",sum);
    return 0;
}