#include <stdio.h>

int main(){
    unsigned long long int n, sum = 0;

    scanf("%lld", &n);

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