#include <stdio.h>

int main(void){
    long int n,i, sum=0;
    scanf("%ld",&n);
    long int a[n];

    for(i=0;i<n;i++){
        a[i] = i+1;
        if(a[i]%3 == 0 || a[i]%5 ==0){
            a[i]=0;
        }
    }

    for(i=0;i<n;i++){
        sum += a[i];
    }

    printf("%ld",sum);

}