#include<stdio.h>

int main(void){
    double N, Sum = 0.0;

    scanf("%lf",&N);

    for(int i = 1; i <= N; i++){
        if(i%3 != 0 && i%5 != 0){
            Sum += i;
        }
    }
    printf("%.0f\n",Sum);
    return 0;
}