#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    int n;
    cin >> n;
    ll sum = 0;
    for (ll i=0; i<n; i++) {
        if ((i+1)%3==0 || (i+1)%5==0) continue;
        sum += (i+1);
    }
    
    
    
    
    cout << sum << endl;
    return 0;
}
