#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
void solve(long long N){

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    cin >> N;
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        if(i % 3 == 0){
            continue;
        } else if(i % 5 == 0){
            continue;
        }  else { 
            ans += i;
        }

    }
    cout << ans << endl;
}
