#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}


int main() {
    ll n;
    cin >> n;
    ll ans = 0;

    for (ll i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0) {

        } else {
            ans += i;
        }

    }

    cout << ans << endl;

    return 0;
}