#include <stdio.h>

int main(void) {
    unsigned long int i, count, sum, n;
    scanf("%lu", &n);

    for (i = 0, count = 0, sum = 0; i <= n; i++ ) {
        if (i % 3 != 0 && i % 5 != 0) {
            count++;
            sum += i;
        }
    }

    printf("%lu\n", sum);
    return 0;
}