#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define INF (1LL<<31)-1
//#define MOD 998244353
#define MOD 1000000007

int main(){
    ll n;
    cin>>n;
    ll ans=0;
    rep(i,1,n+1){
        if((i%3)&&(i%5))ans+=i;
    }
    cout<<ans;
    
}