#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define pb push_back
#define all(con) (con).begin(),(con).end()
#define zoro ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N=1e5+5;
const int mod=1e9+7;
void solve();
signed main(){
    zoro;
    int tests=1;
    // cin>>tests;
    while(tests--){
        solve();
    }
return 0;
}
void solve(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        if( i%3==0 || i%5==0 ){
            // ans+=i;
        }
        else{
            ans+=i;
        }
    }
    cout<<ans<<endl;
}

