#include <bits/stdc++.h>
using namespace std;


int main(){
    int N;
    int64_t sum=0;
    cin>>N;
    for (int i=0;i<N;i++){
        if((i+1)%3==0){
            continue;
        }
        else if((i+1)%5==0){
            continue;
        }
        else{
            sum+=i+1;
        }
    }
    cout<<sum<<endl;
    
    
    
}