#include <stdio.h>

int main(void) {
    int N;
    scanf("%d", &N);

    unsigned long long result = 0;
    int i = 0;
    for (i = 1; i <= N; i++) {
        if (i % 3 != 0) {
            if (i % 5 != 0) {
            result += (unsigned long long)i;
            }
        }
    }

    printf("%lld\n", result);
    return 0;
}