#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    long long int n,ans;
    cin>>n;
    for(long long int i=0;i<n;i++){
        if(i%3!=0&&i%5!=0){
            ans=ans+i;
        }
        else{}
    }
    cout<<ans<<endl;
    return 0;
}