    #include <stdio.h>

    int main()      /*this code is written by 190042146*/
{
    int n, i;
    long long int sum=0;

    scanf("%d", &n);

    for (i=1;i<=n;i++)
    {
        if (i%3==0 || i%5==0)
        {
            continue;
        }
        sum=sum+i;
    }

    printf("%lld",sum);


    return 0;
}
