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