#include<stdio.h>
#define ll long long
using namespace std;

int main(){
    ll n;
    scanf("%lld", &n);

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