#include <iostream>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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