#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>

#define max 100

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int count_digit(int a){int i=0;while (a!=0) {a=a/10;i++;}return i;}

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

