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

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

    printf("%lld",sum);


    return 0;
}