#include<stdio.h>
 
int main(void)
{
    long N, i, total=0;

    scanf("%ld", &N);

    for(i=1; i<=N; i++) {
        if(i%3 == 0 || i%5 == 0) {
            continue;
        } else {
            total += i;
        }
    }

    printf("%ld\n", total);
    
    return 0;
}