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


int main(){
    unsigned long N,i,M,sum;

    scanf("%d", &N);

    sum = N * (double)(N + 1) / 2.0;
    M = 0;
    for (i = 0; i <= N; i+=3)
    {
        M += i;
    }
    for (i = 0; i <= N; i += 5)
    {
        if(i % 3 == 0){
            continue;
        }
        M += i;
    }

    printf("%ld",sum - M);

    return 0;
}
