#include<stdio.h>

int main(void){
    int n, i;
    long s;

    scanf("%d",&n);

    s = 0;
    for(i=1; i<=n; i++){
        if((i%3 != 0)&&(i%5 != 0))
            s = s + i;
    }
    printf("%ld\n",s);
    return 0;
}