#include<iostream>

using namespace std;

int main(void)

{
    unsigned long long int a, i, sum = 0;
    cin>>a;
    for(i = 1; i <= a; i++){
        if(i%3 == 0 || i%5 == 0){

        }
        else{
            sum += i;
        }
    }
    cout<<sum<<"\n";
    return 0;
}
