#include <stdio.h>

int main(void)
{
    unsigned long long int N, answer = 0;
    scanf("%llu", &N);

    for (int i = 1; i <= N; i++)
    {
        if (i%3 == 0 || i%5 == 0)
        {
            continue;
        }
        
        answer += i;
    }

    printf("%llu", answer);
    
    return 0;
}