#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int


static long long c[1000001];

int main()
{
    ll N ;
    scanf("%lld",&N);

    memset(c,0,sizeof(c[0]) * N);

    for (ll i = 1; i<=N; i++)
        c[i]=i;

    for (ll i = 1; i<=N; i++)
    {
        if (c[i]%3==0 && c[i]%5==0)
            c[i]=0;

        else if (c[i]%3==0  && c[i]%5!=0)
            c[i]=0;
        else if (c[i]%3!=0  && c[i]%5==0)
            c[i]=0;
    }

    ll sum = 0;
    for (ll i = 1; i<=N; i++)
        sum+=c[i];

    printf("%lld",sum);

    return 0;

}
