#include <stdio.h>

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

    scanf("%d", &num);

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

    printf("%d", sum);

    return 0;
}