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

const ll INF = 1LL << 60;

ll N;
int main() {
    cin >> N;

    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 15 == 0) continue;
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}