#include<stdio.h>
typedef long long ll;
int main(){
    ll N;
    scanf("%lld",&N);
    ll sum = 0;
    for(int i=0;i<N;i++){
        if(!(i%5==0 || i%3==0))
            sum += i;
    }
    printf("%lld",sum);
}
