#include <iostream>
using namespace std;
int main(void){
    long long int N;
    cin>>N;
    long long int count=0;
    for(int i=1;i<=N;i++){
        if(i%3!=0 & i%5!=0){
            count+=i;
        }
    }
    cout<<count<<endl;
}
