#include <stdio.h>

int main() 
{
    int n;
    int array[1000000] = {0};
    unsigned long long int sum = 0;
    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        array[i] = i + 1;
        if ((array[i] % 3 != 0) && (array[i] % 5 != 0))
        {
            sum += array[i];    
        }
    }
    printf("%llu\n", sum);
}    
