#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    ll n;cin>>n;
    ll sum=0;
    rep(i,n+1){
        if(i%3!=0 and i%5!=0) sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}