#include <algorithm>
#include <iostream>
#include <string>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

// 158 - c
int main(void) {
    int n;
    cin >> n;

    ll sum = 0;
    repe(val, 1, n) {
        if (val % 3 != 0 && val % 5 != 0) sum += val;
    }

    cout << sum << endl;

    return 0;
}
