#include <stdio.h>
#include <math.h>
int main(void) {
    int i, n;
    int sum = 0;
    while(1) {
        scanf("%d", &n);
        if(1 <= n && n <= 10^6) {
            break;
        }
        else {
            continue;
        }
    }
    for(i = 1; i <= n; i++) {
        if(i%3 == 0 && i%5 == 0) {
            continue;
        }
        else if(i%3 == 0) {
            continue;
        }
        else if(i%5 == 0) {
            continue;
        }
        else {
            sum = i + sum;
        }
    }
    printf("%d\n", sum);
    return 0;
}