#include "stdio.h"

int main(void)
{
    int a[1000001];
    int i;
    int j=1;
    for(i=1;i<1000001;i++)
    {
        if(i%5==0)
        {
            a[i] = 0;
        }
        else if(i%3==0)
        {
            a[i] = 0;
        }

        else
        {
            a[i] = i;
        }
        
    }

    long int N;
    long int kei=0;
    scanf("%ld",&N);
    for(i=1;i<=N;i++)
    {
        kei = kei + a[i];
    }
    printf("%ld",kei);
}