#include<stdio.h>

int main(){
    int n;
    unsigned long int sum = 0;
    scanf("%d",&n);

    for(unsigned long int i=1;i<=n;i++)
    {
        if(i%3 != 0 && i%5 != 0){
            sum = sum + i;
        }
    }
    
    printf("%lu\n",sum);

    return 0;
}