#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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