#include <stdio.h>

int main (void)
{
    long N;
    scanf("%ld", &N);
    long S = 0;
    long i;
    for (i = 1; i < N+1; i++) {
        S += (i%3!=0)&&(i%5!=0)? i: 0;
    }

    printf("%ld", S);

    return 0;
}