#include <stdio.h>

int main(void)
{
    long int N;
    long int sum = 0;
    scanf("%ld", &N);

    for(long int j = 0; j < N; j++){
        if((j + 1) % 3)
            if((j + 1) % 5)
                sum = sum + j + 1;
    }
    printf("%ld\n", sum);
    return 0;
}