#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    int sum=0,i;
    for(i=1; i<=n; i++){
        if(i%3==0||i%5==0) continue;
        sum+=i;
    }
    printf("%d\n",sum);
    return 0;
}