#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    Int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (!(i % 15 == 0 || i % 5 == 0 || i % 3 == 0)) {
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}