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