#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;

void a(){
    string n; cin >> n;
    if(n.find_first_of("7")!=string::npos){
        cout << "Yes"<<endl;
    }else{
        cout << "No"<<endl;
    }
}

void b(){
    ll n; cin >> n;
    ll sum =0;
    for(ll i=1;i<=n;i++){
        if(i%3==0&&i%5==0) continue;
        else if(i%3==0) continue;
        else if(i%5==0) continue;
        else sum+=i; 
    }
    cout << sum << endl;
}

void c(){

}

void d(){

}

void e(){

}

int main(){
    b();
    return 0;
}