#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>


int main(void) {

    char buf[8];
    uint64_t N;
    uint64_t div3,div5,div15;
    uint64_t sum3,sum5,sum15;
    uint64_t sum;
    char *p;
    p = fgets(buf, 8, stdin);

    N = strtoul(p,0,0);

    sum = ((1+N)*N)/2;

    div3 = N /3;
    div5 = N/5;
    div15 = N/15;
    sum3 = (((1+div3) * div3) /2) * 3;
    sum5 = (((1+div5) * div5) /2) * 5;
    sum15 = (((1+div15) * div15) /2) * 15;
    
    printf("%lu\n", sum - sum3 - sum5 + sum15);

    return 0;
}
