#include <stdio.h>


int main(void) {

int N;
unsigned long int a[1000000];
unsigned long int sum;
int i;

sum = 0;

scanf("%d", &N);

for (i = 0; i < N; i++) {

    a[i] = i + 1;
    //printf("a[%d]=%d\n", i, a[i]);

    if(a[i] % 3 == 0 || a[i] % 5 == 0) sum = sum;
    else sum += a[i];

    //printf("sum = %d\n", sum);
}

printf("%ld\n", sum);

return 0;

}