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

int main(void){
    int n, ii1;
    long sum = 0;
    scanf("%d", &n);
    for(ii1=0; ii1<=n; ii1++){
        if(ii1%5!=0 && ii1%3!=0)
          sum += ii1;
    }
    printf("%ld\n", sum);

    return 0;
}
