#include <stdio.h>
int main(void){
    long long int n;
    scanf("%lld", &n);

    long long int sum = 0, sumall = 0;
    for(long long int i = 1; i <= n; i++){
        if(i%3 == 0 || i%5 == 0){
            sum = sum + i;
        }
    }

    for(long long int i = 1; i <= n; i++){
        sumall = sumall + i;
    }

    sum = sumall - sum;
    printf("%lld", sum);
    return 0;
}