#include<stdio.h>
int main()
{
    int i,n,count;
    scanf("%d",&n);
    count=0;
    for(i=1;i<=n;i++)
    {
            count=count+i;

    }
    for(i=1;i<=n;i++)
    {
        if(i%3==0||i%5==0)
            count=count-i;
    }
    printf("%d\n",count);
}