#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    lint ret = 0;
    for (lint i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0)
            ret += i;
    }
    cout << ret << "\n";
    return 0;
}