#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<vector>
#include<string>
#include<algorithm>
#include<bitset>
typedef long long ll;

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define MOD 1000000007;
using namespace std;
ll n;
int main(){
    cin>>n;
    ll ans=0;
    rep(i,1,n+1){
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    puts(ans);
}

