#include <stdio.h>

int main(void){
    long long sum = 0;
    int s;
    scanf("%d",&s);
    for(int i = 0; i <= s; i++){
        if(i%3!=0 && i%5!=0){
            sum += i;
        }
    }
    printf("%lld",sum);

}
