#include <stdio.h>

int main(void){
    int num;
    long int sum = 0;

    scanf("%d", &num);

    for (int i = 1; i <= num; i++){
        if (i%3 != 0 && i% 5 != 0)
            sum += i;
    }

    printf("%ld", sum);

    return 0;
}