//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n; cin >> n;

    ll ans = 0;
    for(int i = 1; i<=n; i++) {
        if(i%3==0) {
        }else if(i%5 == 0) {
        }else if(i%3 == 0 && i%5 == 0) {
        }else{
            ans += i;
        }
    }
    cout << ans << endl;

    return 0;
}