#include<stdio.h>
int main()
{
    long long int n,s=0,i=1;
    scanf("%lld",&n);
    while(i<=n)
    {
        if(i%3!=0&&i%5!=0&&i%15!=0)
        {
            s=s+i;
        }
        i++;
    }
    printf("%lld\n",s);
    return 0;
}
