#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define COUT(x) cout << (x) << endl
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;


int main() {
    int n;
    cin >> n;
    ll ans = 0;
    rrep(i, n) {
        if((i % 3 == 0) || (i % 5 == 0)) continue;
        ans += i;
    }
    COUT(ans);
    
    return 0;
}